0

I want to trigger mouse down event of combo box/selection box using javascript. here is the code, it is working perfect in crome but not in Firefox. any help on this ??

<select id="dropdown">
    <option value="Red">Red</option>
    <option value="Green">Green</option>
    <option value="Blue">Blue</option>
</select>
<br>
<button id="fire" type="button" onclick="runThis()">Show dropdown items</button>

// <select> element displays its options on mousedown, not click.
showDropdown = function (element) {
    var event;
    event = document.createEvent('MouseEvents');
    //event.initMouseEvent('mousedown', true, true, window);
    event.initMouseEvent('mousedown', true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
    element.dispatchEvent(event);
};

// This isn't magic.
window.runThis = function () {
    var dropdown = document.getElementById('dropdown');
    showDropdown(dropdown);
};

Thanks in advance....

CPP
  • 47
  • 2
  • 7
  • is `element.click()` good enough? –  Oct 30 '12 at 11:48
  • @H2CO3 - no, what i want is, when user click some option in drop down then it loads the data in this and select that option but i want to keep that drop down open.. compare this in crome and FF and see the difference : http://jsfiddle.net/fz2sY/106/ – CPP Oct 30 '12 at 12:03
  • I am having the same issue and can't find out anything! Since when doesn't `mousedown` work at all in Firefox?? – WebWanderer Jul 30 '14 at 21:35

1 Answers1

0

It just seems that this in not possible. See similar questions:

Community
  • 1
  • 1
Matthias
  • 7,432
  • 6
  • 55
  • 88