onpageloadstring

How do you use onPageLoad in Javascript?

人走茶凉 提交于 2021-01-21 07:58:05
问题 I tried using onPageLoad: function() { alert("hi"); } but it won't work. I need it for a Firefox extension. Any suggestions please? 回答1: If you want to do this in vanilla javascript, just use the window.onload event handler. window.onload = function() { alert('hi!'); } 回答2: var itsloading = window.onload; or <body onload="doSomething();"></body> //this calls your javascript function doSomething for your example <script language="javascript"> function sayhi() { alert("hi") } </script> <body