Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Not work in IE

  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    121
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Not work in IE

    The below code work in Crome but not in IE

    Code:
    <script language=JavaScript>
    var sTestEventType='mousedown';
    function handleMouseEvent(e) {
    var evt = (e==null ? event:e);
    if (evt.type!=sTestEventType) return true;
    if (evt.which==1)  return true; 
    return false;
    }
    document.onmousedown=handleMouseEvent;
    document.onmouseup=handleMouseEvent;
    document.onclick=handleMouseEvent;
    </script>
    Can anyone help to modify for working in IE. Thanks

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,480
    Thanks
    0
    Thanked 635 Times in 625 Posts
    Perhaps the following (although I don't know why you are testing for the key from the keyboard having a code of 1 - a code that actually corresponds to a character on the keyboard would be more useful as it could actually be entered and the if statement satisfied).

    Code:
    <script type="text/javascript>
    var sTestEventType='mousedown';
    function handleMouseEvent(event) {
    if (event.type!=sTestEventType) return true;
    if (((event.charCode) ? event.charCode : event.keyCode)==1)  return true; 
    return false;
    }
    window.onmousedown=handleMouseEvent;
    window.onmouseup=handleMouseEvent;
    window.onclick=handleMouseEvent;
    </script>
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    121
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    Perhaps the following (although I don't know why you are testing for the key from the keyboard having a code of 1 - a code that actually corresponds to a character on the keyboard would be more useful as it could actually be entered and the if statement satisfied).

    Code:
    <script type="text/javascript>
    var sTestEventType='mousedown';
    function handleMouseEvent(event) {
    if (event.type!=sTestEventType) return true;
    if (((event.charCode) ? event.charCode : event.keyCode)==1)  return true; 
    return false;
    }
    window.onmousedown=handleMouseEvent;
    window.onmouseup=handleMouseEvent;
    window.onclick=handleMouseEvent;
    </script>
    Not test for a key, I just want to send the return=false if right mouse clicked


  •  

    Posting Permissions

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