Important alert: (current site time 7/15/2013 1:13:44 PM EDT)
 

VB icon

Activate image link only when ctrl is pressed

Email
Submitted on: 6/5/1998
By: Found on the Web 
Level: Not Given
User Rating: By 2 Users
Compatibility: JavaScript
Views: 11552
 
     Is it possible to have an image which is not an active link unless the ctrl key is depressed when clicking? Found on the web at:http://www.irt.org
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Activate image link only when ctrl is pressed
' Description:Is it possible to have an image which is not an active link unless the ctrl key is depressed when clicking?
Found on the web at:http://www.irt.org
' By: Found on the Web
'**************************************

This will workas required in NN4 and MSIE4: 
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function checkFirst(url) {
location.href = url;
}
//--></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2"><!--
var when = new Date();
var what = '';
function netscapeKeyPress(e) {
if (e.modifiers == 2) {
// Ctrl key pressed
when = new Date();
what = 'Ctrl';
}
}
function microsoftKeyPress() {
if (window.event.ctrlKey) {
// Ctrl key pressed
when = new Date();
what = 'Ctrl';
}
}
if (navigator.appName == 'Netscape') {
window.captureEvents(Event.KEYPRESS);
window.onKeyPress = netscapeKeyPress;
}
function checkFirst(url) {
var now = new Date();
var difference = Date.UTC(now.getYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds())
- Date.UTC(when.getYear(),when.getMonth(),when.getDate(),when.getHours(),when.getMinutes(),when.getSeconds());
if (difference < 1000)
location.href = url;
}
//--></SCRIPT>
</HEAD>
<BODY onKeyPress="microsoftKeyPress()">
<A HREF="javascript:checkFirst()"><IMG SRC="picture.gif" WIDTH="100" HEIGHT="100" BORDER="0"></A>
</BODY>
</HTML>
 


Other 219 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/23/2000 4:37:32 AMJustin

Very handy
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.