I found that Safari does not support click() of Jquery.
So I have the following two implementations for 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 than Safari:
document.getElementById(some_id.id).click();
Now, my problem is, if I put both pieces into my code, I have to apply some sort of conditional to check, if one fails, use the other. Yet I'm unable to find a way to check that.
When I use document.getElementById(some_id.id).click(); Safari gives the following error:
TypeError: 'undefined' is not a function (evaluating 'document.getElementById(del_id.id).click()')
How could I catch&handle this error, or check if this error occurs in a conditional? So I could make the code to try the other piece?
I tried typeof (document.getElementById(some_id.id).click()) == undefined
but no luck.
Thanks,