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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Click Command

Status
Not open for further replies.

charIie

Programmer
Feb 14, 2006
21
US
Hello,
I'm in the process of developing my website, and am pretty much a newbie to javascript. I am working on a part where when the reader clicks with the left button on an image it opens a new window. Is there a way that you can do this also with the right click? I would like the left click to go to one page and the right click to go to a different.

Thanks,
Charlie

Here is my script for the left click.
-----------------------------------
<SCRIPT language="JavaScript">
<!--hide

function originalshirt(){
window.open('page.htm','Close Up','width=534,height=469');
}
//-->
</SCRIPT>

... then the link
<a href="Close Up" onClick="originalshirt();return false;">Image</a>
 
For the code you've shown you should not even be using an anchor, as you're not taking the user anywhere. I suggest the following:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--

		function originalShirtOne() {
			window.open('page1.htm','Close Up','width=534,height=469');
		}

		function originalShirtTwo() {
			window.open('page2.htm','Close Up','width=534,height=469');
		}

	//-->
	</script>
</head>

<body>
	<span style="cursor:pointer;" onclick="originalShirtOne();" oncontextmenu="originalShirtTwo(); return(false);">Close Up (or img tag, etc etc)</span>
</body>
</html>

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
For some reason this does not work in IE? Any reason why? and how can this be corrected?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top