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?

0

2 Answers 2

7

Why string concatenation of course!

"width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no"
Sign up to request clarification or add additional context in comments.

Comments

5
window.open(href, windowname, "width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no" );

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.