html - Run javascript function on load -
i trying use script run function on page load. can see what's wrong? stupid error, i'm sure - can't work out.
code:
<script> var text = document.getelementbyid("mytext"); function changefontsize(){ if (window.innerwidth < 600) { text.style.fontsize = "70px"; } else { text.style.fontsize = "100px"; } } window.onresize = changefontsize; </script> <script> settimeout(function() changefontsize, 3000); </script>
window.onload = changefontsize; window.onresize = changefontsize;
alternatively, can use
window.addeventlistener("onload", changefontsize, false); window.addeventlistener("onresize", changefontsize, false);
Comments
Post a Comment