user244394
user244394

Reputation: 13488

Javascript passing value to open window

How do i go about passing the value of width ,height,resize received as parameter to window.open using javascript?

Thanks

Example

function poponload(mywidth,myheight,resizeVal)
{
   testwindow = window.open ("http://www.yahoo.com", "mywindow","location=1,status=1,scrollbars=1,width=+mywidth+,height=myheight,resizeVal");
   testwindow.moveTo(0,0);
}

<body onload="javascript: poponload(200, 500,yes)">

Upvotes: 0

Views: 477

Answers (3)

Humberto
Humberto

Reputation: 7199

Also, body onload="javascript: poponload(200, 500,yes)" is one javascript: too many.

Upvotes: 0

sushil bharwani
sushil bharwani

Reputation: 30207

testwindow= window.open ("http://www.yahoo.com", "mywindow","location=1,status=1,scrollbars=1,width="+mywidth+",height="+myheight+",resizeVal");

use this see the string concatenation

Upvotes: 3

Ricket
Ricket

Reputation: 34085

function poponload(mywidth,myheight,resizeVal) {
    testwindow= window.open("http://www.yahoo.com", "mywindow", "location=1,status=1,scrollbars=1,width="+mywidth+",height="+myheight+",resizable="+resizeVal);
    testwindow.moveTo(0,0);
}

Also you should then pass in "1" or "0" for resizeVal, like so:

<body onload="poponload(200,500,1)">

Further reading:

Upvotes: 5

Related Questions