0

I have this function:

javascript:

function popup(mylink, windowname, w, h)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, "width=w,height=h,scrollbars=yes,toolbar=no" );
return false;
}

html:

<a href="test.html"  onClick="return popup(this, 'Test', '400', '600')">test</a>

Im trying to insert variable w and h in the string but without success. What is the proper way to do it in javascript?

Below the Radar
  • 7,321
  • 11
  • 63
  • 142

2 Answers2

7

Why string concatenation of course!

"width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no"
tymeJV
  • 103,943
  • 14
  • 161
  • 157
5
window.open(href, windowname, "width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no" );
Scott Mermelstein
  • 15,174
  • 4
  • 48
  • 76