SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Tacoma, WA
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Closing Parent window without prompt cross browser

    What I wanted to do is have it so the parent window will pop up a child and then the parent will close without a prompt.

    onClick="window.open('2.htm','newWindow','width=1024,height=768,toolbar=no,scrollbars=no,resizable=no,location=no,directories=no,menubar=no'); window.open('','_parent',''); windowClose();">close parent window</a>

    and I had a function:

    function windowClose() {
    window.open('','_parent','');
    window.close();
    }

    and that didn't work for firefox.

    Am I missing something?

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If you didn't open the window uusing Javascript that runs on your domain then you can't close the window without asking permission. Depending on the security settings in the browser such requests will either be discarded or will prompt for permission.

    The only way to close browser windows without a prompt is to open them first using window.open() and then since you opened it you are allowed to close it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    close parent winndow

    Quote Originally Posted by t3projects
    What I wanted to do is have it so the parent window will pop up a child and then the parent will close without a prompt.
    Why not simply redirect from the parent page to the popup page?

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and that didn't work for firefox.
    ...as if it works in IE.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Tacoma, WA
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually 7stud I got it to work in IE.

    felgall you can close the window without the prompt in IE.

    So if you can do it in IE there's gotta be a way to do this in Firefox.

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So if you can do it in IE there's gotta be a way to do this in Firefox.
    So if a script works in a broken browser that's ridden with security flaws, it should work in all browsers. Other browser vendors aim for something higher than IE.

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Tacoma, WA
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry 7dud I'm not seeing how that is a bad thing.

    I have a pop up window for an eLearning course that launches a chromeless window. There are links within that window that launch other pop ups and what's happening is that I need to get variables from the course page (not the original page) but it's trying to get variables from the orginal page.

    When I close that original page then it works. So I need to close that original page without alerting the user and confusing them.

    The web isn't always used by developers it's used by people that freak out about every little alert or message. So there's no need to add confusion to the user for something this simple.

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    closing window

    Again, why not use location.href instead of window.open ?
    As to dialog boxes freaking out users, this may be more true with security type dialogs, but I think if you clearly and noticeably state that the parent window must be closed (maybe near the link that is clicked to open the spawn) I think most users will take it in stride.


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
  •