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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -