替代< body onload =" init();"> [英] Alternative to <body onload="init ();">
本文介绍了替代< body onload =" init();">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试修复为我编写的旧脚本。我需要它在没有< body onload =init();>
的情况下运行。我想从脚本内部运行该函数而不使用像该命令那样的内联代码。对不起,我不是JS专家,但我该怎么做?
I'm trying to fix an old script written for me. I need it to run without <body onload="init ();">
. I'd like to run the function from inside the script without inline code like that command. Sorry I'm not a JS expert but how do I do this?
推荐答案
<script type="text/javascript">
function init() {
// Put your code here
}
window.onload = init;
</script>
或者,如果您使用的是jQuery:
Or, if you are using jQuery:
$(function() {
// Your code here
});
这篇关于替代< body onload =" init();">的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文