I am setting up the following code to allow me decide which JS functions/files to run based on conditional PHP echos to the array given. For some reason I seem unable to retrieve the contents of the array in the Javascript code given:
HTML
<!-- add functions to run at window.onload here -->
<script type="text/javascript">
on_multiload [0] = "message";
on_multiload [1] = "message2";
</script>
<script type="text/javascript" src="http://www.ondesign.org.uk/wp-content/plugins/on-dev-kit/js/pageload.js"></script>
JS
window.onload = function () {
on_multiFunction_load (on_multiload);
}
function on_multiFunction_load (on_multiload) {
for (var i = 0; i< on_multiload.length; i++) {
alert (on_multiload[i]);
}
}
Can anyone see what I’ve done wrong (first time loading js variables from an external source, so it’s likely to be simple)?
You are trying to assign values to properties of
on_multiloadwhileon_multiloadisundefined.or