-4

Possible Duplicate:
$(document).ready equivalent without jQuery

I want to wait until an ASP.NET datagrid is resized correctly before showing a popup message. This works great:

$(document).ready(function () { showpopup(); });

But I need to acheive it without jQuery. I've tried many ways:

$(window).bind("load", function() {showpopup();}

$(function() { showPopup();}

but this doesn't work.

Community
  • 1
  • 1
anmarti
  • 4,785
  • 10
  • 48
  • 92

1 Answers1

3

My preferred method of doing such things is to start my script with:

var loadScripts = [],
    loadScript = function(callback) {loadScripts.push(callback);

Then, the very last thing on the page before </body> is:

<script type="text/javascript">(function() {var x; while(x=loadScripts.shift()) x();})();</script>

Then, whenever there's something I want to defer until the DOM has loaded, I simply enclose it in:

loadScript(function() {
    // do stuff here
});
Niet the Dark Absol
  • 301,028
  • 70
  • 427
  • 540