0

jQuery(window).load() not working properly in IE, especially in IE 8 and below. I need to call one method after loading the window completely.

But in IE the window shows after executing the function given in jQuery(window).load() also.

.
.
.
.
</body>
<script language="javascript">
jQuery(window).load(function(){
    renderEditNView();
});
</script>
</html>

Even an alert within the load method shows before the window loads. How will I fix it?

7
  • document.ready not good for you? Commented Jun 28, 2013 at 10:53
  • 1
    try to use $(document).ready instead of jQuery(window).load and see if it helps Commented Jun 28, 2013 at 10:54
  • @Cherniv: it will not help. it comes before the page load. I checked with an alert. Commented Jun 28, 2013 at 10:58
  • what jQuery version in use? Commented Jun 28, 2013 at 10:58
  • 1
    if you tried $(document).ready(function(){ /* code */}); and you can call any dom element from within the /*code*/ in the page then it is working properly, but you might have a different expectation for the functionality in your mind ,, it is not for after loading the contetns data, but rather the document's elements, or the window it self if it is shown in case of $(window).ready.. Commented Jun 28, 2013 at 11:13

5 Answers 5

2

try this I hope it works on your browser too

$(window)[0].onload = (function(){alert('done');});

javascript :

window.onload = (function(){alert('done');});

note: even your code is working on chrome and jQuery 1.9.1!

Sign up to request clarification or add additional context in comments.

Comments

1

See document http://api.jquery.com/load-event/

In general, it is not necessary to wait for all images to be fully loaded. If code can be executed earlier, it is usually best to place it in a handler sent to the .ready() method.

Comments

1

Use any method call Inside $(function() :

<script type="text/javascript">
    $(function(){
       alert('Alert box after page Completely Ready');
       renderEditNView();
    });

    function renderEditNView(){
         alert('Render Edit and View after Page Competely ready');
    }
</script>

Comments

1

Try to put the script code inside the body tag (at the end for example). IE might be have some problems with that if the renderEditNView is changing the DOM...

See this question for more info

Comments

0

I tested all of the responses offered and all of them is not working, I am trying to get the outerHeight using $("#element").outerHewight(); after the page is loaded and always is returning 0 because I need to know the height after to fill the data. What I tested is:

<script type="text/javascript">
   // it is no working
   window.onload = (function(){alert($("#myelement").outerHeight());});

   // It is no workking
   $(window)[0].onload = (function(){alert($("#myelement").outerHeight());});

</script>

If I am not mistaken, $("#myelement").outerHeight(), should return some value after the page is loaded, why is returning 0?

For this reason I think both pruposed option arent right.

I can not use pluggin.

I am using Internet Explorer 8. (I can not changhe of navigator)

I wrote in this question because it is quite similar what we are looking for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.