dimanche 22 mars 2015

Open HTML select dropdown programmatically


I am trying to open programmatically a select box (html dropdown/select box, notfile picker) in javascript using this code


http://ift.tt/1HoAWtC



function openSelect() {

var element = document.getElementById("s")
var worked = false;
if (document.createEvent) { // all browsers
var e = document.createEvent("MouseEvents");
e.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);


worked = element.dispatchEvent(e);

} else if (element.fireEvent) { // ie
worked = element.fireEvent("onmousedown");
}

}


but only seems to work in chrome. Not in ie 11 not in firefox.


Anyone any ideas?


Thanks





Aucun commentaire:

Enregistrer un commentaire