[Javascript] replace

matthew garland mgarland at rpa.com
Tue Oct 23 14:43:55 CDT 2001


Hi,

Learning a little Javacript beyond "window.open". Hope you can help. 
This is the set up: I have two frames on a page: "home" with a home.html page, and "dummy" with a blank dummy.html page. The home frame has a Flash movie embedded in it. The dummy frame is an invisible one-pixel frame. 
When I want to communicate between Flash and the window, only one action is supported in all 4.0+ browsers--the link or Flash "getURL()" command. So the workaround is this: the Flash calls a page into the "dummy" frame (getURL ("aPopUP.html","dummy"//to target the frame), which in turn executes Javascript within the onload handler. 
This works like a charm, and I use it to call pop ups from the Flash movie.

But here's the problem: when the user tries to leave the site, and hits the back button, all the pop ups come up again, because the back button is retreading the history of the window. Each dummy page is called up again, and "onload"--the pop up comes up. YRRECH! Annoying, especially since my site is a FLash site that loads a lot of long text in pop ups. 
I only know enough Javascript to open pop ups, but my reseach has led me to at least one solution: if every time the dummy pages loaded, they fired off the pop ups, then waited a second and then used the replace command to return the location of the dummy frame back to the original "dummy.html," there would be no history and the back button would take you right out of the site, with no retread of the pop ups. 
but I can't get the code to work: 
{//in the header of each dummy page

function popUp () 
window.open (page,window,features)

}

function eraseHistory() {

setTimeout ('location.replace('dummy.html')',1000)

}

//in the onload handler of the dummy page

onload="popUp();eraseHistory()"

Not only does this not work, it makes the pop Up not work! Is there something wrong with my code? I know nothing.Help!

Thanks in advance

Matt



More information about the Javascript mailing list