Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Document | Q584 [ previous next ]

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?'

©2018 Martin Webb