javascript - How to check if click() is defined for the browser? -
i found safari not support click() of jquery.
so have following 2 implementations click event:
for safari:
var foo = document.getelementbyid(some_id.id); var ce= document.createevent("mouseevent"); ce.initevent("click", true, true); foo.dispatchevent(ce); for other browsers other safari:
document.getelementbyid(some_id.id).click(); now, problem is, if put both pieces code, have apply sort of conditional check, if 1 fails, use other. yet i'm unable find way check that.
when use document.getelementbyid(some_id.id).click(); safari gives following error:
typeerror: 'undefined' not function (evaluating 'document.getelementbyid(del_id.id).click()')
how catch&handle error, or check if error occurs in conditional? make code try other piece?
i tried typeof (document.getelementbyid(some_id.id).click()) == undefined no luck.
thanks,
remove parenthesis. in comparison use only: .click === undefined.
Comments
Post a Comment