When closing popup box, takes user back to homepage

Hi, can somebody please help me? For my php site, when users close a popup window for email subscriptions, it takes them to the homepage rather than staying on the current page. If I hit refresh, it takes me back to the page that I’m suppose to be on. I think this is the code that I’m dealing with:

$(’#’ + popID).fadeIn().css({ ‘width’: Number( popWidth ) }).prepend(’<a href=“http://<?php echo $_SERVER["HTTP_HOST"] ;?>/” class=“close”>’);

Any suggestions? I know in javascript you can make it auto refresh, but I’m not sure how to for php. Thanks in advance for the help!

Just use a REDIRECT. Which tell the browser to switch pages…

window.location.replace(“http://wherever.you.want.to.go.com”);

Note, if it is a popup, then the popup might get redirected, so you would have to use the parent’s command not the current window’s…

parent.window.location.replace(…); Good luck…

Hi ErnieAlex, thanks for the prompt reply. I can’t give it an exact url. I’m not sure how to explain it, but here’s how the site works:

The admin adds a deal using the CMS and the deal is created on a new page. When a user goes to that page by clicking on a link from an external site, the popup appears to ask the user to sign in. When the user signs in or closes the popup, it’s suppose to stay on the current page (the page with the deal), but it goes to the homepage of the site instead. I wouldn’t be able to change the code and give it a direct URL every time so is there some way to fix the code so that it stays on the current page rather than going to the homepage?

Please help. Thanks!

Sorry, I was away…

I think you just need to remove the redirect in you pop-up code. But, I do not think the code you posted: ( $(’#’ + popID).fadeIn().css({ ‘width’: Number( popWidth ) }).prepend(’<a href=“http://<?php echo $_SERVER["HTTP_HOST"] ;?>/” class=“close”>’); ), was the code that moves it back to the home page.

If so, then, you could try this instead:

$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="" class="close"></a>');

That would remove the link which was pointing to the server’s home page. It might work. Try it. If is does not work, post a few lines before and after it so we can see the flow of the code…
Good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service