Where did that window go?
November 21, 2006 7:53 AM Subscribe
Javascript / HTML : Let's say I have a page called 'foo.html' that opens a new window using the command window.open('http://ask.metafilter.com','newWindow'). Now let's say I navigate AWAY from my original page 'foo.html' to a page call 'bar.html' still leaving 'newWindow' open. Is there anyway I can get a handle on 'newWindow' from 'bar.html' even though I have navigated away from its opener 'foo.html'? I basically want to be able to change the url of 'newWindow' at anytime from any page on my website. Alternate solutions accepted.
Not really Javascript, but if you put target="whatever" in links you want to open in the window, the first link clicked will open a new window and, as long as you use the same name for target, every subsequent link will also open in that window.
posted by cillit bang at 8:10 AM on November 21, 2006
posted by cillit bang at 8:10 AM on November 21, 2006
Anything that sends a URI to newWindow will refresh newWindow. So if bar.html contains the following link: <a href="grit.html" target="newWindow">, then grit.html will open in newWindow.
On preview: what cillit bang says.
posted by ardgedee at 8:24 AM on November 21, 2006
On preview: what cillit bang says.
posted by ardgedee at 8:24 AM on November 21, 2006
Your javascript will, likewise keep sending the URL to the same window. So "window.open(URL1,'newWindow',[config])" followed by "window.open(URL2,'newWindow',[config])" will open URL2 in the same window as URL1. If the window with URL1 has been closed, it'll just open another one with the same name.
posted by mkultra at 8:26 AM on November 21, 2006
posted by mkultra at 8:26 AM on November 21, 2006
This thread is closed to new comments.
I did something similar once and it worked fine; it was a while ago so I don't have the precise code for passing handles between parent and child frames, but I think it's easier than passing them from request to request (if that latter is even possible). Good luck.
posted by rkent at 8:08 AM on November 21, 2006