By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Is it possible to block a mouse event on an Hyperlink with a general script event

P: n/a
Is it possible to block a mouse event on an Hyperlink with a general
script event?

This is quite troublesome for me. I am trying to find a way to block
the windows shortcut SHIFT + MOUSE LEFT BUTTON that open the Hyperlink
in a new window for a Web application. I just want to capture the Shift
click event and prevent it from opening a new page.

Mouse Wheel didn't pose any problems but the other mouse buttons seems
to ignore the cancelBubble proprety.

I'v seen few messages of people saying that they couldn't not make it
work with IE6 and some answers what it did work with IE5. I couldn't
try on IE5 but I tried it on IE7Beta and it Dindn't work.

As I sayd before, only the mouse button seems to not work. Mouse Wheel
work fine.

It may be because the activation of the event click on an Hypertext
have an higher priority than the event in the code and therefore the
annulation of the bubble is useless since the action have been alredy
launch but if if you add a MsgBox("") in the code, there is no new page
opened.

If anyone have a clue about how to solve my problem I would really
appreciate.

P.S.: A way to pass by this problem could be to remove the SHIFT
modificator and simply open a page the normal way but I coudn't find
anything on that either. (But I don't NEED the page to be open on a
shift click, just blocking the event would be really nice)

<script language="vbscript" for="document" event="onmousedown">
<!--
IF window.event.shiftKey THEN
window.event.returnValue = FALSE
window.event.cancelBubble = TRUE
END IF
//-->
</script>
<script language="vbscript" for="document" event="onmouseclick">
<!--
IF window.event.shiftKey THEN
window.event.returnValue = FALSE
window.event.cancelBubble = TRUE
END IF
//-->
</script>
<script language="vbscript" for="document" event="onmouseup">
<!--
IF window.event.shiftKey THEN
window.event.returnValue = FALSE
window.event.cancelBubble = TRUE
END IF
//-->
</script>


<script language="vbscript" for="document" event="onmousewheel">
<!--
IF window.event.shiftKey THEN
window.event.returnValue = FALSE
window.event.cancelBubble = TRUE
END IF
//-->
</script>

Thank you for your time

Mar 31 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.