Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q584 How do I let all my scripts pre-load before they are executed?

irt.org | Knowledge Base | JavaScript | Document | Q584 [ previous next ]

Q584 How do I let all my scripts pre-load before they are executed?

Set a variable boolean flag to false at the top of your page, and then use the BODY tags onLoad event handler to set it to true, then when accessing your JavaScript functions you can check to see if the flag is true before continuing:

<html>
<head>
<script language="JavaScript"><!--
var myFlag = false;

function functionName() {
    // code only executed when all JavaScript loaded
}
//--></script>
</head>

<body onLoad="myFlag=true">
...
<form>
<input type="button" onClick="if (myFlag) functionName()" value="Click Me">
</form>
...
</body>
</html>

Feedback on 'Q584 How do I let all my scripts pre-load before they are executed?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.