SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good morning / afternoon / evening and season's greetings to you all.

    I'm trying to help a friend out. When a page is requested, he activates a javascript function using the onLoad. The function opens a new window of a particular size, and he wants to close the original window.

    It all seems to work ok, but the window.close function activates a pop-up prompt (i'm sure you know the one: "The web page you are viewing is trying to close the window"). I realise the importance of this prompt for security reasons but is there any way round it using a slightly modified script?

    If anyone knows a way in PHP, this will be just as good.

    Thanks in advance for any help anyone can give! ;-)

    Jon.

  2. #2
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, and season's greetings to you too

    The security message you just mentioned (this browser is trying to close this window) is an in-built feature of the browser, so no amount of programming will get you around it. It's pre-dominantly a security measure to protect 'innocent' surfers against malicious coders.

    That msg actually doesn't appear in older browsers, but it's a standard thing from version 4.x onwards.

    So in other words, you'd have to break open the browser code to get rid of it

    Hope this helps.
    My 2 Cents (or is that 2.2 Cents including GST?)

  3. #3
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah. It works fine with a minor change:

    <a href="javascript: self.close()">go back</a>


    Owen

  4. #4
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Errr.... That's the same as above. Still get the 'trying to close this window' error. (on IE)

    Works in Netscape though
    <Edited by BC on 12-13-2000 at 07:02 PM>
    My 2 Cents (or is that 2.2 Cents including GST?)

  5. #5
    SitePoint Enthusiast raynebair's Avatar
    Join Date
    Dec 2000
    Location
    Alabama
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using:

    <a href="" onclick="self.close">Close this Window</a>

    and it works with no prompt.

  6. #6
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Funny it works on one of my sites with no problem. See http://www.pbbt.com/ (only first visit... cookie prevents repeat popups.) Maybe it doesn't complain if the window is opened by java script in the first place (as I think someone already said)...

    Owen

  7. #7
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very interesting... I should have a better look at this later on...
    My 2 Cents (or is that 2.2 Cents including GST?)

  8. #8
    cd /pub; more beer diacono's Avatar
    Join Date
    Dec 2000
    Location
    Horsham, West Sussex, UK
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i've been on somewebsite that dont ask me with ie5 but with the same pc on ie5 some pages do ask me....

    i was kind of about to ask the same...

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the window was originally opened by a script from the same server as the document currently loaded in the window, then there will be no prompt. Basically, the browser trusts a single site to open and close windows as it wishes, but for one site to open a window and then a different site to close it, the browser prefers to be safe and make sure the user agrees with that action.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  10. #10
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Although this will work fine in Netscape browsers and on IE for the Mac, I have never, ever been able to make it work on IE/Windows without the alert when the parent window tries to close itself.

    If someone can show me a working example of this, I'd love to see it.

  11. #11
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by "when the parent window tries to close itself"?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  12. #12
    SitePoint Zealot Jppr's Avatar
    Join Date
    Dec 2000
    Location
    Belgium
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Kevin says, you will only get such a msg, if the page to close was not opened by some script on the same server as the page giving the self.close() command.
    Thomas


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
  •