Click to See Complete Forum and Search --> : open in new window using right click


aqua
08-02-2003, 06:47 AM
the code i have is

<html>
<head>
<script>

function next()
{
location.href="next.html";
}

</head>
<body>
<a href="" onClick="next();return false" >Click me</a>
</body>
</html>

this code workd fine. now if i right click on the link i see the pop up menu. how do i trap this event and how do i know which item the mouse is referring to..

like now if i right click on the link and say open it opens a blank page in the new window. that is because i have used the onClick event . so to achieve this i need to trap the right click event and know what to do even each of the menu item is clicked in the pop up menu..


anybody with any ideas how to do it??:confused:

AdamGundry
08-02-2003, 09:02 AM
Why aren't you just using <a href="next.html">Click me</a> ? Using Javascript makes your page inaccessibile to the 13% or so of web users who have it disabled.

Adam

pyro
08-02-2003, 09:05 AM
You should just write you code differently, which will have the added benefit of keeping yoiu pages working for those with javascript disabled (13% of web users).

Here's the code that is valid, and will degrade well (though, I can't see any purpose for useing javascript at all, here...)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Link Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><a href="next.html" onclick="window.location.href=this.href; return false;">test</a></p>
</body>
</html>

aqua
08-04-2003, 05:46 AM
thanks a lot.. :)

actually the code is sent was just a snippet. actually i have to do some more things on click .. so was calling a javascript function..

SearedIce
08-04-2003, 09:33 AM
:) yeah i've learned from experience in these forums that its best to post as much code as possible. Otherwise people don't understand WHY you need help and thus might give a perfectly good answer, but for a different question. But its a good idea not to let these people know about your bad coding habits too. Last time i asked about a javascript in one of my pages people started flaming me about how i used an iframe in the html :rolleyes: