Reputation: 792
I have a javascript file and inside it there are some functions. I can call them on my rails app view through onclick events like: ...onclick="myFunnyFunction();"... and it works. But now I want to call this myFunnyFunction(); using the onload event like: onload="myFunnyFunction();". Both calls are in the same view file (one in a button and one in a div) and the onclick event work but the onload event don't. The div is showing the html properly so it is loaded.
Any suggestion?
Thanks in advance.
Upvotes: 0
Views: 392
Reputation: 20418
If body onload not works mean try this , operations are same
window.onLoad = doStuff()
function doStuff() {
alert("test")
}
you cant do it div onload method but its posible you put script after div it will work
<div id="somid">Some content</div>
<script type="text/javascript">
yourfunction()
</script>
Upvotes: 2