Is it better to use <body onEvent=""> or <

Is it better to use <body onEvent=""> or <script>window.onevent=function(){}?</script>

本文关键字:quot lt it gt or onEvent body to Is better use      更新时间:2023-09-26

我试过用谷歌搜索,但我无法表达我想要的内容。

似乎有不同的方式来触发事件,我想知道它们之间是否有区别。

On way是例如:

window.onload=function(){headerAdjustWidth();thumbsArrange();checkHash();}
window.onscroll=function(){windowScrollStore();}
window.onresize=function(){headerAdjustWidth();thumbsArrange();windowScrollAdjust();showExpanded(false);}
window.onkeydown=function(){checkKeyboard();}
另一种方法是
<body onKeyDown="checkKeyboard();" onLoad="headerAdjustWidth();thumbsArrange();checkHash();" onScroll="windowScrollStore();" onResize="headerAdjustWidth();thumbsArrange();windowScrollAdjust();showExpanded(false);">

到目前为止,每一个都有什么优点/缺点吗?

另一件事是对于onload函数,有没有什么理由我应该/不应该直接把它们放在