Results 1 to 2 of 2

Thread: opener.location.reload.grrrr

  1. #1
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question opener.location.reload.grrrr

    Not sure if my problem is in my php or my javascript, but here goes.

    I have page 1 that has my form and below that fields that I populate from a mysql DB. The user can click on "add employee". here page 2 pops open with a list of employees, the user checks the employee they want to add, then when they click add the window closes and page 1 should refresh and show the new user below the form. Here is where my problem is... after page 2 closes, page 1 goes blank and sits there reloading until I get a network error. After that error I can view the page with the new employee has been added.
    Anyone know whats going on?

    On page 1 i'm using window.open

    My reload code on pg. 2 is:
    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
        opener.location.reload(true);
        self.close();
    // -->
    </script>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, your scriptlet, as is, would execute as soon as the page it is on parses it. You probably have it, or would want to have it, as a function activated onclick or on some event on the page. Second, reloading a page will generally get you that page as it is written, without any updated information. If all you want to do is update information on the opener, simply access or create an element on it, adding the new information:

    Code:
    <script type="text/javascript">
    function updateOpener(){
    var box=opener.document.createElement('input')
    box.type='text'
    box.value='new employee'
    opener.document.body.appendChild(box)
    self.close()
    }
    </script>
    HTML Code:
    <input type="button" value="Update" onclick="updateOpener();">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •