Hi folks,
I'm trying to create a link that points to URL 1 normally and to URL 2 when the shift key is held down. I arrived at this code sample, which properly switches the links (as indicated in the browser status bar when hovering over the link), but clicking on URL 2 doesn't work: the browser just doesn't do anything. That's right: a link is present, but clicking it just doesn't do anything.
Tried this in Firefox 3.6.6 and Safari 5.0, same result in both.
Any hints? Thanks!
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script>
$(document).keydown(function(event) {
if (event.keyCode == '16') {
$("#mylink").text("My Link Extended");
$("#mylink").attr("href", "http://www.google.com/");
}
});
$(document).keyup(function(event) {
if (event.keyCode == '16') {
$("#mylink").text("My Link");
$("#mylink").attr("href", "bla");
}
});
</script>
<a href="normalurl" id="mylink">My Link</a>