View Full Version : Javascript Redirect - Please Read, Complicated Task

10-15-2005, 10:21 AM
Hello, ok here is the scenereo I have created a popup to load an offsite game into it. And when they register to play the game it loads there homepage, which is fine but what I need to do is for it to redirect them back to the origonal popup. Let me give you some links so you can test it for yourself so you get a better understanding

click on the big graphic titled Adventure Quest, it will open in a popup window

Now when you goto register to play the game
(please test this its free registration) it takes you to there homepage after you go through the registration process you can even enter false information it dont matter. This all still done inside the popup window on my site.

It takes you to there homepage which is http://www.battleon.com what I am trying to do is I thought If i added an iframe with like 1 width and height and placed a code in there that was something like:

if load"http://www.battleon.com"
redirect to http://infernozard.battleon.com/build30/game.asp

and this would only trigger from the iframe if the page thats in the popup is http://www.battleon.com

Thank you in advance for any help on this matter

10-16-2005, 09:37 AM
This is just a thought. I have no idea if it would work.

Create a new html page that would open in the popup when you clicked the game link. Inside that page create an iframe and have the external site load in that iframe. You could get away with using a width and height of 100% for the iframe since you don't really need the space for anything else. Then add the code below to the page that contains the iframe.

//top frame
parent.frames[1].document.onload = function() {
if (parent.frames[1].document.location.href == "http://externalsite.com") {
window.location.href = "http://yoursite.com";

That should check the frame url everytime it loads a new page. If it finds a match then it redirects back to your page. You may have to tweak it a bit, such as changing the frames[] index number or adding the parent.frames[] to the window.location. But I'm pretty sure it should work.

If it doesn't work, you may have to use the old fashion way for creating frames. Create a page containing a frameset tag and name each frame src. Then create a separate file for the first frame src that includes the function listed above. And set the src of the second frame to the external site url.