Passing a javascript variable inside window.open
I have a function that opens a new window when a button is pressed. However i want to pass a global variable in the link. This is what i have and stops the window opening altogether:
function submitChk(){
window.open ("http://localhost/date/chk.php?"+<strong>check</strong>+",
"mywindow","width=300,height=300, location=yes");
}
check is the variable im trying to pass.
Abhishek Reddy posted this at 21:06 — 16th February 2007.
He has: 3,348 posts
Joined: Jul 2001
If you do something like this:
var mywin = window.open ("http://localhost/date/chk.php", "mywindow","width=300,height=300, location=yes");
mywin.foo = "value";
You'll find [incode]foo[/incode] is available to Javascript in the new window.
If you want the Javascript variable to be passed by HTTP request, then you would do something like what you tried, without syntax errors:
var mywin = window.open ("http://localhost/date/chk.php?check="+check, "mywindow","width=300,height=300, location=yes");
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.