Hi all, My browser is firefox. I have the piece of code <html> <head> <script type="text/Javascript"> function load(url,event) { location.href=url; } </script> </head> <body> <a href="http://www.yahoo.com" onClick="load('http://www.google.com'); return false;">Yahoo</a> </body> </html> The code works fine when i press left button. But it will not redirect me to google when i press both middle and right(open link in new tab). Then i tried this. <html> <head> <script type="text/Javascript"> function load(url,event) { var button = event.which; //document.write(button); if(button==1) { window.location = url; } if(button==2) { window.open(url); } } </script> </head> <body> <a href="http://www.yahoo.com" onMouseDown="load('http://www.google.com',event); return false;">Yahoo</a> </body> </html> It is displaying button values but unable to redirect. So How can i redirect to google when i click yahoo link in all the three cases. regards kiran
<html> <head> <script type="text/Javascript"> function load(url) { window.open(url,'_blank','scrollbar=yes') ; } </script> </head> <body> <a href=# onClick="load('http://www.google.com'); return false;">Yahoo</a> </body> </html> Code (markup): This js code open in a new window. I have try some way to open in a new tab, but it doesn't works. Sorry. Arief
Hey, remember to use onclick="" instead of onClick="", you can't capitalize "click" in the new w3 standards