www.webdeveloper.com
Results 1 to 7 of 7

Thread: window.close() HEADACHE

  1. #1
    Join Date
    Oct 2008
    Posts
    15

    window.close() HEADACHE

    I'm having an issue with a simple javascript.

    I have 5 html pages all the same except different videos embedded. Each page links to the other pages and all pages have this code:

    <a href="javascript:window.close();">Close</a>

    This works fine when the page first opens.

    The problem is when from the first page you click on one of the links and it loads, then the "close" button doesn't function.

    I'm not a developer and don't know much JS. Does anybody know what's going on here? It's driving me nuts.

    Thanks in advance

    Here's a link so you can see what I'm talking about:
    www.aninconvenienttax.com/video1.html

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    See if this works better. JavaScript doesn't run properly from the href attribute.

    <a href="#" onclick="window.close();return false;">Close</a>

  3. #3
    Join Date
    Oct 2008
    Posts
    15
    It doesn't seem to work

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774
    It could be that when you click a link in the pop up window, and the page loads, the current page you are looking at didn't open the pop up window and browsers now prevent you from closing a window using JavaScript which JavaScript did not open.

  5. #5
    Join Date
    Oct 2008
    Posts
    15
    Yeah, the original page is opened from a flash ActionScript, getURL("http://......");

    The thing is, when the page is first called by the AS the JS "close" works fine.

    So how do you close a window not opened by JS?

  6. #6
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

  7. #7
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    If you want to close a window with JavaScript then you must open it from JavaScript.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles