onload

Setting OnLoad event for newly opened window in IE6

Hey folks- I need to set the onload attribute for a newly popped-up window. The following code works for Firefox: <a onclick="printwindow=window.open('www.google.com');printwindow.document.body.onload=self.print();return false;" href='www.google.com'> However, when I try this in IE, I get an error - "printwindow.document.body null or ...

A resonable request: Iframes in IE that indicate loading progress?

One thing that bugs me about IE is that when it goes to load a page with an iframe it will wait until the iframe has finished loading before it will render the page. Firefox by contrast will render all the other page elements while the iframe is loading which is really nice if the iframe takes a long time to load because it gives the us...

Best way to cancel a slow loading remote JS call

I have a remote JS that must appear in the head of the document. If the server is slow to respond or inaccessible, obviously this slows or prevents the page from loading. I have been searching for a simple way to set a limit of say 3 seconds (probably less) for it to give up and simply not load the functionality. Does anyone have a si...

showModelessDialog - onLoad failure - IE 7

MSIE v7 does not (in my hands) open a Modeless Dialog or trigger an onLoad event if there is a Javascript alert in the target page. The following fails in MSIE v7 but is OK in v6 (zip file of full source available if required). Would appreciate others confirming this and discussing why this should be so. index.htm (only javascript fun...

Javascript Window.Onload Function Chaining

Just for the sake of experimentation, I've been trying to determine different ways to non-destructively chain window.onload functions in a web browser. This is the idea of what I have so far: var load = window.onload; var newFunction = function(){ alert("ha!"); } window.onload = function(){ load(); newFunction(); } The pro...

possibility of jQuery document ready() function taking a very long time to execute

My issue is that sometimes a piece of JavaScript (often Google Analytics) may take a very long time to load, although it's not important to the HTML be ready to be "traversed and manipulated". If I were to use the following code: $(document).ready(function () { $("p").text("The DOM is now loaded and can be manipulated."); }); woul...

Why does Visual Studio give you Page_Load for WebForms as a default?

When creating a new WebForm, Visual Studios creates a Page_Load handler in the code behind as a default, which is cool. So for years, I have always put code for doing things like set properties of controls in Page_Load. Recently, I used Reflector to look at some assemblies written by Microsoft and saw that they have put the same type o...

Dojo addOnLoad, but is Dojo loaded?

I've encountered what seems like a chicken & egg problem, and have what I think is a logical solution. However, it occurred to me that others must have encountered something similar, so I figured I'd float it out there for the masses. The situation is that I want to use dojo's addOnLoad function to queue up a number of callbacks which ...

Best Practices for onload Javascript

What is the best way to handle several different onload scripts spread across many pages? For example, I have 50 different pages, and on each page I want to set a different button click handler when the dom is ready. Is it best to set onclicks like this on each individual page, <a id="link1" href="#" onclick="myFunc()" /> Or a very...

onload from external js file

I'm writing a js script that people will add to their web site by adding a single line of code to the header or end of the body part of their HTML. My question is how to do the onload right on the external js file. Will the code below work? Can't it possibly run after the onload of the document and miss the onload event? function c_onl...

google.setOnLoadCallback with jQuery $(document).ready(), is it OK to mix?

I'm using Google Ajax API and they suggest I use google.setOnLoadCallback() to do various things related to their API but I'm using also jQuery's $(document).ready() to do other JS things, not related to Google API. Is it safe to mix these two approaches in one document? I did not notice any problems yet but I suppose it's a matter of s...

Best practice for using window.onload

I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded. Most of the time this is done using the window.onload function. My question is: Is this the best way to trigger JavaScript events on the page loading or is there a better...

Can I assume that DOM is not ready yet on dynamically loaded JS script?

I have written an external script that needs to run after DOM is ready (or after onload if thats impossible). I use this method to load the script dynamically since I need parameters on the script: <script type="text/javascript"> document.write(unescape("%3Cscript src='mydomain.com/script.js.php?u="+encodeURIComponent(window.location.h...

jquery document ready in external script

My page has an outside script that contains some jQuery. Most of it runs fine except this bit: $(document).ready(function(){ alert('x'); }); That bit of code works fine when i run it inside the HTML page but not in the .js file. I have no other library in the HTML, i do have a window.onload inside the HTML but if i remov...

Can you put the JavaScript onload event anywhere besides in the body tag?

I'm familiar with the typical use of onload, as in the following: <body onload="alert('Hello, World!');"> ... </body> Is there anywhere else in a page that onload is valid? I can experiment to see if it will work in <script>...</script> tags, but it might save me some time if anyone knows all the places that it's valid to use onload....

Onload set divs opacity to 50%

Okay, so I have a site running Joomla and it is using the mootools 1.11 framework. I've fudged together a working version of this using examples from the mootools 1.2 framework but cannot get the two to co-exist even with the compatibility layer, without breaking other modules in the Joomla site. Question I have a couple of divs with a ...

window.onload delay

i am trying to appendChild() on an existing form, and its not working. i wonder if i need to delay the page, at least i thought i read that somewhere. what i am thinking is dynamically altering window onload to be a delay. do i grab the body tag like any other DOM element? ...

Exactly when does an IFRAME onload event fire?

Does the IFRAME's onload event fire when the HTML has fully downloaded, or only when all dependent elements load as well? (css/js/img) ...

jQuery/Javascript: How to tell if the $(window).load()/window.onload event has already fired?

I have a script that is being inserted dynamically via another script. The code in that script is wrapped inside the $(window).load() event because it requires the images on the page to have all loaded. In some browsers it works fine, but in others it seems not to fire because the page has already finished loading by the time the code ...

How do I trigger a Javascript function AFTER the page loads?

** EDIT ** I'm afraid I wasn't in the right direction - the problem isn't what I asked about. the Javascript works as it should, it's the PHP that doesn't show what I want it to on the first "run" - and I'm stil not sure why. Sorry for somewhat wasting your time... ** I have a form that might or might not already contain data in its f...