0

This code is working fine..

<a href="http://google.com/" onmouseover="window.location=this.href">Text</a>

But I need to open the link in a new tab

Ahmed
  • 255
  • 2
  • 7
  • 17
  • wait. onmouseover to navigate to new page? seems a strange user experience (UX). and `onmouseover` is not supported in touch devices. – Raptor Jul 05 '13 at 02:33
  • possible duplicate of [JavaScript: location.href to open in new window/tab?](http://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab) – Raptor Jul 05 '13 at 02:35
  • do some googling dude there are lots of answers for this already – Vignesh Subramanian Jul 05 '13 at 02:49
  • @ShivanRaptor, I mean new window/tab not tablets or touch devices.....window.open('http://www.google.com', '_blank');.....open in new window but I need in new tab not new window! – Ahmed Jul 05 '13 at 03:07

2 Answers2

1

Instead of using window.location, you can use:

window.open('http://www.google.com', '_blank');

to open in new window.

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • window.open('google.com';, '_blank');.....open in new window but I need in new tab not new window! – Ahmed Jul 05 '13 at 03:10
  • Read this: http://stackoverflow.com/a/4907854/188331 . No script can control the new content be open in new tab / new window. Depends on browser settings ! – Raptor Jul 05 '13 at 05:44
0

You can use it. But New Window

<a href="#" onmouseover="javascript:window.open('http://google.com')">Text</a>

OR use javascript. This New TAB

<a href="#" onmouseover="myFunction()">Text</a>
<script>
function myFunction() {
    var Open = window.open("http://www.kangsigit.com", "_blank");
}
</script>
Norax
  • 111
  • 7