Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript problem closing a Window.

    Hi:

    I have link in my page when clicked it's supposed to close the window. The window is in a frame :

    <frameset rows="72,*" frameborder="NO" border="0" framespacing="0" cols="*">
    <frame name="topFrame" scrolling="NO" src="topbannerportal.asp?Loggedin=true">
    <frame name="mainFrame" src="door.asp">

    </frameset>

    Now how can I close the window. I have a link in the top frame src page like this:
    <a href="javascript:document.close();" > <font Color = "black"> <B> LogOff </B> </FONT> </a>

    But when I click on the link it does nothing. Can I close the window without the alert window popup asking yes or no to close the window.

    Can some please help.

    Thanks for you help in advnace
    Last edited by javaspace; 04-04-2003 at 03:55 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    something like this could work:

    self.opener = top;self.close()

    but not in all browsers, however
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    document.close closes a stream opened with document.open. It's window.close you want, that closes a window (ithout prompting only if it's been opened by window.open of the current window)
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by liorean
    (without prompting only if it's been opened by window.open of the current window)
    yes, but using self.opener = top; bypasses the warning in IE and just closes it.

    Grmph. I don't approve
    Last edited by brothercake; 04-04-2003 at 07:42 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    How utterly ridiculus - you shouldn't be able to overwrite window.opener or anything else that describes factual information. What if we allowed overwriting of other properties, like document.referrer, navigator.mimeTypes or screen.availWidth?
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by liorean
    How utterly ridiculus - you shouldn't be able to overwrite window.opener or anything else that describes factual information. What if we allowed overwriting of other properties, like document.referrer, navigator.mimeTypes or screen.availWidth?
    Just don't get me started
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    A way round this is to add the following to a function

    window.opener = top;
    window.close()


  • #8
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Mr J
    A way round this is to add the following to a function

    window.opener = top;
    window.close()


    lol, seems that somebody has not read the previous posts
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #9
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    lol, seems that somebody has not read the previous posts
    On the contrary, but it appears no one was getting anywhere other than debate the issue



  • #10
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't want to enter the debate but just want clarification, please.

    Only when the window was opened outside of JavaScript, window.close() was producing the alert in IE running on XP most of the time, but never in IE running on ME. I was trying to get rid of the alert as well, so I tried

    self.opener = top;self.close()

    which Borgtex suggested and it seems to work, on IE/XP in that no alert comes up.

    then, I read further into the thread and found some disapproved, but didn't understand why. Even Borgtex said "but not in all browsers, however"

    I just want to know if there is a risk of this thing not working on some browser/OS combo.

    if not, it seems to solve my difficulty with the alert, which is a bother. I have written an application where I prefer it closed.

    thanks
    charliek


  •  

    Posting Permissions

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