Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

right click

Status
Not open for further replies.

jcroft

Programmer
Aug 23, 2001
52
US
I have searched for two days...my problem is that I do not know enough about javascript to know when I have the answer..

I can capture the left click with this code...

<SCRIPT Language=&quot;Javascript&quot;>
function post_to_link(link_loc){
 document.form1.action =
link_loc;
  document.form1.submit();
  }
</SCRIPT>

I have been trying to capture the right click...I can capture it with onmouseup event but then I loose the information that would make the user be able to &quot;save as&quot;

I need really beginner level instructions from anyone who wants to take the time, and I thank you.

JCroft
--only those that do not try, fail--
 
also

Question: How do I check whether the user clicked the left or right mouse button?

Answer: The click event occurs for the left mouse button only. Therefore, onClick event handlers do not need to preform the left-versus-right button test.

On the other hand, the mousedown and mouseup events may occur for any mouse button. To determine whether the user clicked the left or right button, you can use the following event properties:

event.which in Netscape Navigator
event.button in Internet Explorer
If the value of these properties is 1, the event occurred for the left button. In the following example, the onMouseDown event handler displays the messages Left button or Right button, depending on the mouse button you actually have clicked. The messages will appear on your browser's status bar. Click or right-click anywhere on this page to see it work:

<script language=&quot;JavaScript&quot;>
<!--
function mouseDown(e) {
if (parseInt(navigator.appVersion)>3) {
var clickType=1;
if (navigator.appName==&quot;Netscape&quot;) clickType=e.which;
else clickType=event.button;
if (clickType==1) self.status='Left button!';
if (clickType!=1) self.status='Right button!';
}
return true;
}
if (parseInt(navigator.appVersion)>3) {
document.onmousedown = mouseDown;
if (navigator.appName==&quot;Netscape&quot;)
document.captureEvents(Event.MOUSEDOWN);
}
//-->
</script>


admin@onpntwebdesigns.com
 
Thank you for your help...I am trying them out, if I have any more troubel I will ask again.

JCroft
--only those that do not try, fail--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top