Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 3 of 3

This is a discussion on Adding onmousewheel via javascript within the Chrome Troubleshooting section, part of the Google Chrome category: With Chrome, adding onmousewheel via html, such as <table onmousewheel="myFunkl(event)"> works fine. However this is not standard html and so ...


  1. #1
    stephenwaring is offline Junior Member
    Join Date
    Jan 2010
    Posts
    2

    Default Adding onmousewheel via javascript

    With Chrome, adding onmousewheel via html, such as
    <table onmousewheel="myFunkl(event)">
    works fine.

    However this is not standard html and so cannot be used with strict XHTML.

    Normally I would use the following javascript:
    if (window.addEventListener)
    {
    myElement.addEventListener('DOMMouseScroll', myFunk, false);
    }
    else
    {
    myElement.onmousewheel = myFunk;
    // or myElement.attachEvent('onmousewheel', myFunk);
    }

    The "then" part of the "if" statement runs, but the onmousewheel event is not added to the element.

    How do you add an onmousewheel event with Javascript in Chrome?

  2. #2
    stephenwaring is offline Junior Member
    Join Date
    Jan 2010
    Posts
    2

    Lightbulb I have found the answer

    if (window.addEventListener)
    {
    myElement.addEventListener('DOMMouseScroll', myFunk, false);
    myElement.addEventListener('mousewheel', myFunk, false);
    }
    else
    {
    myElement.onmousewheel = myFunk;
    // or myElement.attachEvent('onmousewheel', myFunk);
    }

  3. #3
    sulasno's Avatar
    sulasno is offline Super Moderator
    Join Date
    Sep 2008
    Location
    Bangkok
    Posts
    1,759

Similar Threads

  1. Adding item to context menu on right-click on link
    By afin in forum Plugins Development
    Replies: 5
    Last Post: 11-20-2010, 05:05 AM
  2. Javascript not interpreted
    By mleneveut in forum Bugs and Vulnerabilities
    Replies: 3
    Last Post: 11-26-2009, 08:59 AM
  3. problems with javascript
    By p.fil in forum Chrome Troubleshooting
    Replies: 1
    Last Post: 10-04-2009, 03:19 AM
  4. Extensions adding a process
    By Anomaly in forum Chrome Talk
    Replies: 4
    Last Post: 09-19-2009, 05:23 PM
  5. Adding Bookmarks Problems
    By spxtrader in forum Chrome Troubleshooting
    Replies: 1
    Last Post: 09-14-2009, 11:27 PM

Tags for this Thread

Posting Permissions

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