kiransarv
11-16-2008, 07:32 AM
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
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