By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

body onresize vs window.onresize

P: n/a
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?

Nov 29 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Tony wrote:
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
Nov 29 '05 #2

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


Ah - that explains it!

I had been using the second method, but I couldn't figure out why. Now
I remember - it wasn't valid HTML!

Thanks!

Nov 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.