Javascript - String concatenation

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?

Answers:

Answer

Why string concatenation of course!

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.