[removed] vs <body onload=“”/>

后端 未结 13 2087
盖世英雄少女心
盖世英雄少女心 2020-11-22 13:45

What exactly is the difference between the window.onload event and the onload event of the body tag? when do I use which and how shoul

13条回答
  •  忘掉有多难
    2020-11-22 14:37

    'so many subjective answers to an objective question. "Unobtrusive" JavaScript is superstition like the old rule to never use gotos. Write code in a way that helps you reliably accomplish your goal, not according to someone's trendy religious beliefs.

    Anyone who finds:

     
    

    to be overly distracting is overly pretentious and doesn't have their priorities straight.

    I normally put my JavaScript code in a separate .js file, but I find nothing cumbersome about hooking event handlers in HTML, which is valid HTML by the way.

提交回复
热议问题