473,513 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

body onresize vs window.onresize

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
2 97076
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
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10185
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only...
2
9950
by: Bas | last post by:
Hello all, I'm trying to create a little script which will save the width of a certain frame into a database, so that every user still has his/her "own" frame width when logging back on. Now,...
2
7118
by: David | last post by:
Greetings, Does anyone know of a workaround for the onresize bug in Firefox? <body onresize="history.go(0)"> I've looked all around and can't seem to find a working workaround. David
1
2719
by: Darrel Yurychuk | last post by:
I'm having a problem getting the window.onresize to work properly. Here is a simple test case I wrote: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">...
2
2017
by: FrankIsHere | last post by:
This should attach the event to the onresize of the window object, but when I try to resize the browser after executing the page it does not work... only after I refresh the page. But then of...
8
7848
by: David Gravereaux | last post by:
Hi, I'm using chunked transfer-coding to send an "unending" page, but IE _NEVER_ fires onresize events until the page is finished. Unfortunately, the page never is "finished". How do I handle...
2
5200
by: yb | last post by:
I am attempting to modify the style of an element (its width) as the window is being resized, in firefox. Long story short, I've tried to use CSS but one particular part of the layout just won't...
6
7786
by: Tweety | last post by:
Hello, I need to display the current Web Browser's Width on my web page. I Tried Screen.width, but it is for the width of the Windows. I tried Window.width, but it doesn't work. What i want...
0
7264
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5689
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.