Forum Moderators: open
Example:
I am at page http://www.example.com
I click on this button and a new window pops up.
The content of the new window says... "You arrived here via http://www.example.com"
So, how do I retrieve the current URL and use it as a variable/field on the next window? I know document.location.href gets the current URL, but don't know how to transfer the data over to new window.
Appreciate any help. Thanks! :)
The best way to transfer a variable to a new window is using
window.name
window.name= "variable to be passed"
mynew="window.location= 'openme.html'"
eval(mynew)
in the window that opens
myvar = window.name >>> myvar = "variable to be passed"
It works for me = remember to change the name after you've extracted the varable.
I'm still having some difficulties because I want it to open as a new (separate) popup window with a fixed size. How can I modify it so that it has similar effect as onClick
eg. <span class="popup" onClick=javascript:window.open("new.htm", width=250,height=250")>new window</span>
(and i think because it opens a new window, the document.referrer doesn't work to transfer the old page URL...)
will I still be able to get the data "myvar = window.name;" in the new window?
Lastly, maybe not an appropriate question to post here, on the new window, if I want to input the "myvar" value (which will generate from javascript) into a database (MySQL) using PhP, is it possible?
Thanks for your advise!