473,651 Members | 2,775 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="doRes ize()">

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 97087
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="doRes ize()">

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.or g/>

`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.or g/>


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
10198
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 horizontally, but also vertically, to fill the space. I took a look at their javascripts, but they are quite complex and convoluted since they make use of many of their own functions designed to work with their web site. Does anybody have a...
2
9964
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, this works ok, though there's one little problem left: when i click the frameborder and drag it around in IE (it's not working in NN, but that's not my goal since it's a very specific CMS) the onResize handler is called literally hundreds of times.
2
7125
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
2727
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"> <html> <head> <title>Test window.onresize</title> <script type="text/javascript"> function resize_func() {
2
2026
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 course that's after the HTTP request. Here is the code: <HTML> <HEAD> <script language="javascript"> function Loadit() { var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
8
7855
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 this?
2
5207
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 do what I need. The javascript solution assigns a function to window.onresize that sets the inline style, it works with one problem -- the handler only gets called after the resizing stops, and so there is noticeable lag before it redraws.
6
7801
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 to do is, if the user resize the Web Browser's Window, upon refresh, the webpage will show the width size of the web browser windows. this will help me in working on Floating Menu on my web page. thanks.
0
8357
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8700
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6158
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.