TypeError: 'undefined' is not a function (evaluating 'link.click ()') Safari

1

How about? I am setting up a page with Wordpress, where you have the possibility of, by pressing a button, you will download a full .csv of all the subscribers to the page. In Chrome, IE and Firefox, this button works, but in Safari it gives me this error.

TypeError: 'undefined' is not a function (evaluating 'link.click()')

The code where I think the error is is as follows

jQuery(document).ready(function () {
jQuery('#subscriber-download').on('click', function () {

From what I read in other pages, it seems that Safari has a compatibility error, or does not like Jquery. How can I solve this? Thanks!

    
asked by Denu Lemos 03.05.2018 в 15:15
source

1 answer

0

Quoting the OS user iqc in English, I translate your answer

If you take a look at the HTML DOM Level 2 specification, the click () function is only defined for HTMLInputElement, so although it is not very easy to use, Safari does not need to implement that. The correct way to trigger an event for modern browsers is in DOM Level 3 events:

Adapt this example to your needs

// Primero crea un evento
var click_ev = document.createEvent("MouseEvents");
// inicia liza el evento
click_ev.initEvent("click", true /* bubble */, true /* cancelable */);
// dispara el evento
document.getElementById("someElement").dispatchEvent(click_ev);
    
answered by 03.05.2018 в 18:08