calling a javascript on page load

153 views Asked by At

I am a newbie in js, so please forgive me if the question is elementary. I am designing a page in maqetta (maqetta.org) and enjoyed using states! the only question I have is it seems that the way it calls the states is as follows: davinci.states.setState('state1')

for example in a button, it is defined a onclick proparty: onclick="davinci.states.setState('state1')"

Now, my question is if i want to load my page in a different state than normal state what should I do?

I tried this:

<script> 
    window.onload=davinci.states.setState('state1')
</script>

but it did not work! I think it should be a very elemantry question but I could not find a solution for it! Can anybody help me on this?

Thanks

1

There are 1 answers

0
Arun P Johny On BEST ANSWER

It should be

window.onload = function(){
    davinci.states.setState('state1')
}

You may also want to refer
http://www.w3schools.com/jsref/event_onload.asp
Best practice for using window.onload
https://developer.mozilla.org/en-US/docs/DOM/window.onload