Results 1 to 2 of 2

Thread: Javascript link: Two functions

  1. #1
    Join Date
    Apr 2011

    Javascript link: Two functions

    Hi everyone.
    I have a link on my site that when you click it, it uses the window.open function. (I have to use window.open for another reason) but when the user clicks the link, a whole new browser window pops up. I want the code to window.open the new page, then close the previous page. Heres my code so far:
    HTML Code:
    <a href="javascript:window.open('page1.html')">CLICK</a><BR>

  2. #2
    Join Date
    Apr 2012
    Why do you want to close the old page? Could you just use location.href = 'new location'; to change the location of the current page?

    If you insist on opening a new page and closing the old one, you can use window.close(); to close the current window, but browsers won't close the main window without asking the user whether they want it to close first. If it's a window that you previously opened using window.open(), then you're free to use window.close() on it.
    joi JavaScript Framework - the sunnier side of 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