www.webdeveloper.com
Results 1 to 5 of 5

Thread: Open a new window and refresh the page

  1. #1
    Join Date
    Oct 2012
    Location
    Quebec
    Posts
    3

    Question Open a new window and refresh the page

    Hi. I am trying to open a link in a new window and refresh the original page at the same time, on one click.

    I tried this but it doesnt work. All it does is refresh the page but doesn't open the link in a new window.

    <a href="my link" target="blank" onClick="javascript:history.go(0)">Click here</a>

    What should I do?

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,123
    Your example was not refreshing the page ... and only opening in the new window for me. Try this:

    <a href="http://www.google.com" target="blank" onClick="javascript:document.location.reload(true)">Click here</a>
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Oct 2012
    Location
    Quebec
    Posts
    3
    Still only refreshing the page for me...
    I'm using firefox. Is it not compatible with this script?

  4. #4
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,123
    It was working in Chrome. Apparently Firefox doesn't like it. This should do the trick though:

    Code:
    <a href="http://www.google.com" target="_blank" onClick="openWindowReload(this)">Click here</a>
    <script>
    			function openWindowReload(link) {
    				var href = link.href;
    				window.open(href,'_blank');
    				document.location.reload(true)
    			}
    		</script>
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  5. #5
    Join Date
    Oct 2012
    Location
    Quebec
    Posts
    3
    It works
    Thanx!

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