SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2010
    0 Post(s)
    0 Thread(s)

    Angry Help,how the way to pop out screen auto closed and go back to specify page??

    I'm newbie on SitePoint and also is a beginner programmer on ASP.

    I meet a troubles on my current project and no idea to fix it up.

    I've a pop out screen is created by Java Script,and this allows user to edit
    or modifier some of data.When clicked submit, my pop out screen will closing and refreshing host page.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    2 Post(s)
    0 Thread(s)
    This is really a Javascript question. Maybe make a post in that forum?
    Ian Anderson

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Vancouver BC Canada
    5 Post(s)
    0 Thread(s)
    Well I suppose it is a JavaScript question but if it's part of an ASP script it's probably a bit more involved than our friends over in JavaScript land can help with. The thing is, you have to refer to the page that opened the pop-up as an opener.document in JavaScript.

    You can direct that opener.document by using opener.document.location = 'somepage.html'. If you want to refresh that page you just direct it back to the page it was on.

    I usually add a little JavaScript and sometimes some ASP if I want to direct my opener page somewhere else in the body tag of my pop-up window. You are using a pop-up window right?

    If you add the following to any pop-up html page it will close and redirect the opener page wherever you want to:
    HTML Code:
    <body onload="window.close();" onunload="opener.document.location = 'somepage.html'">
    Anyway, assuming that you are opening a pop-up window from another page, editing and then once the edit is complete, closing the popup and refreshing the opener window to show the changes, I would add the following code inside the body tag of the pop-up window:

    I create a bodyTag variable that I stick in the body of the pop-up window:
    HTML Code:
    <body <%=bodyTag%>>
    Somewhere in the processing code of my pop-up window I set the value of bodyTag with the code that closes the window and redirects the opener.document back to itself.

    The trick is you have to tell the opener.document.location where you want to refresh it to. So if it's default.asp then you set myReferrer = "default.asp".
    'If the update was successfull, close the window and refresh the main page.
    myReferrer  = "default.asp"
    bodyTag = "onload=""window.close();"" onUnload=""opener.document.location = '"&myReferrer&"'"""
    I often find that where I want to refresh my page is a dynamic page of some sort like default.asp?id=16&date=12/12/2010 so when I open my popup window from the main page I open it and pass it a querystring of arguments that I pull and insert back into myReferrer.

    Make sense?
    Andrew Wasson |
    Principal / Internet Development


Posting Permissions

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