Search code examples
javascriptgreasemonkeyuserscripts

Trigger inline onchange javascript


I'm writing a greasemonkey script that creates an auto-complete search type box which makes it easier to select from a large dropdown on a webpage. The dropdown has inline onchange code which I can't seem to get to trigger when I change the selection using javascript. Any ideas?


Solution

  • Suppose the the page had something like:

    <input onchange="someFunction()">
    

    Then your Greasemonkey JavaScript could change the input value and then call the function using:

    unsafeWindow.someFunction();