SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automatically update main page from a popupwindow

    Does anyone know how to update the main page from a pop upwindow.

    When a popup window reloads (a form is posted to itself) I want the main page to refresh to thereby displaying the details that were interered in the popupwindow.
    It will be PHP/MySQL driven but I need a javascript to automatically reload the main window.

    Any ideas?
    Eternity

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all popup windows have a pointer called "opener" which surprise surprise points to the parent window. So you can do anything to the parent DOM that you like, including setting the current document i.e.

    opener.document.URL = "blahblah.php"
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by dale_burrell
    all popup windows have a pointer called "opener" which surprise surprise points to the parent window. So you can do anything to the parent DOM that you like, including setting the current document i.e.

    opener.document.URL = "blahblah.php"
    Thanks for your reply Dale

    I am quite dense with JavaScript as I hardly use it, 0- but how do I get this to happen automatically?
    Eternity

  4. #4
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont worry about the last post. I just worked it out for my self.

    Cheers Mate
    Eternity

  5. #5
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you said that you want to be able to post a form in the popup and then reload the main window?

    if so then the following should work

    in popup

    [code]
    <script>
    function DoStuff()
    {
    opener.document.URL="FileToLoad.php/asp";
    }
    <script>
    </head>
    <body onLoad="DoStuff();">
    ...
    [code]

    Your script should determine whether or not to plant the onLoad attribute.
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Here's some code I've used to accomplish what you want. Basically, I had the form submit to another page that does the server-side processing but does not display any content, within the popup window, then I had this function update the parent window's page and close itself.
    Code:
    <script language="JavaScript" type="text/javascript">
    	function changeAndClose(){
    		opener.location.href = 'rel_signup.asp';
    		self.close();
    	}
    	setTimeout('changeAndClose()', 500);
    </script>
    Hope this helps!

    --Vinnie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •