body onresize vs window.onresize

T

Tony

If I want to call a function (call it doResize) when the browser window
is resized, is it better to put that in the body tag:

<body onresize="doResize()">

Or is it better to put the call in a script tag in the <head>:

<script type="text/javascript">
window.onresize = doResize;
</script>

Or, is there no practical difference between the two?
 
T

Thomas 'PointedEars' Lahn

Tony said:
If I want to call a function (call it doResize) when the browser
window is resized, is it better to put that in the body tag:

<body onresize="doResize()">

Or is it better to put the call in a script tag in the <head>:

<script type="text/javascript">
window.onresize = doResize;
</script>

Or, is there no practical difference between the two?

There is no `onresize' attribute for the `body' element in Valid HTML:
<URL:http://validator.w3.org/>

`onresize' is a proprietary event handler of the proprietary host object
`window' refers to.

The latter will either work, break on runtime or have no effect at all,
while the former will break in an SGML parser, and may work or have no
effect at all.

<URL:http://www.pointedears.de/scripts/test/whatami>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top