Results 1 to 5 of 5

Thread: Trapping mouse clicks on web page

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Trapping mouse clicks on web page

    Hi,

    I need some code that disables mouse clicks and right clicks on the html page and another to re-enable the mouse clicks.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    http://javascript.internet.com/page-...ght-click.html

    In the code, insert your own variable, depending upon whose value the script may or may not execut.e

  3. #3
    Member
    Join Date
    Jun 2002
    Location
    Delaware
    Posts
    33
    <script language="JavaScript">
    <!--
    // No rightclick script.
    // Find more great scripts and applets at the JavaFile!
    // http://www.javafile.com
    // Do not delete this header!

    var message="Hey I Took A Long Time On This Site And You Are Not Stealing Any Of My Script!"; // Put your message for the alert box between the quotes.

    // Don't edit below!

    function click(e) {
    if (document.all) {
    if (event.button == 2) {
    alert(message);
    return false;
    }
    }
    if (document.layers) {
    if (e.which == 3) {
    alert(message);
    return false;
    }
    }
    }
    if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;
    // -->

    </script>

    This script disables right click, i use it a lot on my sites
    <html>
    <marquee behavior="alternate" width=50%> This is a test </marquee>

  4. #4
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    That only works if you include the message box...there is a way to do it if you don't want a message box, I just need to find it.
    What is the answer to this question?

  5. #5
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    This seems to do the trick:
    Code:
    <script language ="javascript">
    function cancelClick() {
    	window.event.CancelBubble = true;
        	window.event.returnValue = false;
    }
    document.oncontextmenu=cancelClick;
    </script>
    What is the answer to this question?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width