简体   繁体   中英

Some of Jquery function is not working in IE

I am developing an application in ASP.Net using C#. Also there are lots of JQuery function used in my application. The application is working fine in Fire Fox and Google Chrome but some of the function is not working in Internet Explorer 10. In my web page I have defined window.bind("load") function. Under this function several JQuery function will execute. This function is working fine in all browsers except IE 10. The code snippet is as follows:

$(window).bind("load", function () {
        //alert("I am In Window Bind Function");
        all_blur();
        get_all_es();
        loadImage();
    });

In this code snippet, the alert code is commented. this is not working in IE. But if I put the alert code active then it is working fine. that means the following code working fine for me.

$(window).bind("load", function () {
        alert("I am In Window Bind Function");
        all_blur();
        get_all_es();
        loadImage();
    });

But I have to execute this function without alert. How can I do that? Please help me.

In above code when you have alert on , the window gets the time to render the controls on the page, and mean while you click OK on alert, it has all the controls present and the actions can be performed on those.

This is the reason that $(document).ready(function(){}) must be called instead of load. as following

$(document).ready(function () { //alert("I am In Window Bind Function"); all_blur(); get_all_es(); loadImage(); });

Or

$(function () {
        //alert("I am In Window Bind Function");
        all_blur();
        get_all_es();
        loadImage();
    });

The reason could be the time to load all the components. The time taken to come alert is sufficient to load all the components of entire window. It is typical problem in IE especially. So to execute the jQuery after certain time period(you can define it in the following function.)
setTimeout(function() { if ($.browser.msie) { //To confirm the browser as IE(any version) //Your jquery/javascript statements }, 1000); //This is the time limit, define the time period as per your requirement

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM