window.opener issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrboyer79
    New Member
    • Dec 2006
    • 13

    window.opener issue

    hello,

    i have this page where if you leave the page or close the page a pop-up will generate. the pop-up has a button on it to go back to that original page. the code i have works fine if the user just leaves the main page, but i can't figure out how to get it to regenerate the page if the user closes the main page. if that makes any sense and you have some ideas, let me know.

    thanks,
    derek


    i have the following script on my page:

    <script language="JavaS cript">
    function goto_applicatio n()
    {
    window.opener.f ocus();
    window.opener.l ocation.href='w ww.google.com';
    window.close();
    }
    </script>

    and then the link looks like this:

    <a href="javascrip t: goto_applicatio n();">click here</a>
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by mrboyer79
    hello,

    i have this page where if you leave the page or close the page a pop-up will generate. the pop-up has a button on it to go back to that original page. the code i have works fine if the user just leaves the main page, but i can't figure out how to get it to regenerate the page if the user closes the main page. if that makes any sense and you have some ideas, let me know.

    thanks,
    derek


    i have the following script on my page:

    <script language="JavaS cript">
    function goto_applicatio n()
    {
    window.opener.f ocus();
    window.opener.l ocation.href='w ww.google.com';
    window.close();
    }
    </script>

    and then the link looks like this:

    <a href="javascrip t: goto_applicatio n();">click here</a>
    This is not a Java question. I will move it to the Javascript forum.

    Comment

    • mrboyer79
      New Member
      • Dec 2006
      • 13

      #3
      Originally posted by r035198x
      This is not a Java question. I will move it to the Javascript forum.
      thanks, sorry!

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by mrboyer79
        hello,

        i have this page where if you leave the page or close the page a pop-up will generate. the pop-up has a button on it to go back to that original page. the code i have works fine if the user just leaves the main page, but i can't figure out how to get it to regenerate the page if the user closes the main page. if that makes any sense and you have some ideas, let me know.
        When the window is closed, window.opener does not exist anymore. So you will have to open another window.
        So try the following code:
        Code:
        function goto_application()
        {
        	if (window.opener) {
        		window.opener.focus();
        		window.opener.location.href='www.google.com';
        	} else {
        		window.open(...) // your window.open code (you know how to do that!)
        	}
        	window.close();
        }

        Comment

        Working...