javascript Document ready firefox (jQuery)

前端 未结 3 1246
情深已故
情深已故 2021-01-16 03:12

In FireFox I have this jQuery at the end of the body:

$(document).ready(function() {
     $.getScript(\'LiveMapsJavascriptProvider.aspx?type=reference&va         


        
3条回答
  •  青春惊慌失措
    2021-01-16 03:57

    You don't necessarily need to use jQuery for that.

    Simply have an onload function as below:

    
    

    Or you can dynamically attach your function call to the onload event as shown below:

    function addEvent(obj, evType, fn){ 
     if (obj.addEventListener){ 
       obj.addEventListener(evType, fn, false); 
       return true; 
     } else if (obj.attachEvent){ 
       var r = obj.attachEvent("on"+evType, fn); 
       return r; 
     } else { 
       return false; 
     } 
    }
    addEvent(window, 'load', JavascriptFunctionName);
    

    You may embed jQuery functions calls inside the JavascriptFunctionName function.

    EDIT:

    jQuery is also capable of doing that through the following code. I recommend trying that first, for the sake of avoiding unnecessary redundant code.

    $(window).load(function() {
        JavascriptFunctionName();
    });
    

提交回复
热议问题