Emulate clicking a link with Javascript that works with IE

后端 未结 5 923
别那么骄傲
别那么骄傲 2020-12-02 20:40

I want to have java script clicking a link on the page..I found something on the net that suggests adding a function like this:

function fireEvent(obj,evt){
         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 21:22

    Try this if you are still getting error (Use of Jquery + prototype)

    function fireEvent(element,event){  
    if (document.createEventObject){
    // dispatch for IE
    try {
          var evt = document.createEventObject();
          jQuery(element).change();
          return element.fireEvent('on'+event,evt);
    } catch(e) { }                  
    }
    else{
    // dispatch for firefox + others
    var evt = document.createEvent("HTMLEvents");
    evt.initEvent(event, true, true ); // event type,bubbling,cancelable
    return !element.dispatchEvent(evt);
    }
    }
    

提交回复
热议问题