1

I have a site and in my site when user click on a specific div then a new child window open . Suppose the user is standing at xyz.com/category , now if you user clicks on that div then parent windows goes to another url suppose google.com and a popup window will get open and there are some more navigation in popup windows . But every page that will open in popup has a button called Go Back To Site . I want that when user clicks on several links in popup and then click on Go Back To Site button then popup window get closed and parent window move back to xyz.com/category.

Ian
  • 50,146
  • 13
  • 101
  • 111
user2193861
  • 87
  • 1
  • 2
  • 10

3 Answers3

0

You can try PHP Superglobal array

$_SERVER['HTTP_REFERER']
Itsmeromka
  • 3,621
  • 9
  • 46
  • 79
0

If you can use javascript for this, there are simple functions such as:

window.history.back();

window.history.forward();

You can refer all of them in following link:

https://developer.mozilla.org/en/docs/DOM/Manipulating_the_browser_history

For Jquery:

$(document).ready(function() {
   var referrer =  document.referrer;
});

For C# :

WebBrowser1.Url = new Uri("http://maps.google.com");

- document.referrer does not work for IE

For this issue refer following code:

<script type="text/javascript" >            
function redirect(url) {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
        var referLink = document.createElement('a');
        referLink.href = url;
        document.body.appendChild(referLink);
        referLink.click();
    } else {
        location.href = url;
    }
}
</script>

This code can also be refered over here

Community
  • 1
  • 1
Freelancer
  • 9,008
  • 7
  • 42
  • 81
0

The way I'd do it is to pass the current URL as a parameter into your popup. So you would change your anchor link tags to this:

<a href="popup.aspx?prevPage=oldPage.aspx">Click</a>

So when your popup pops up, you just grab the value of prevPage and then when they click "Back to previous page", you just redirect to the value of prevPage.

Icemanind
  • 47,519
  • 50
  • 171
  • 296