AllExperts > Javascript 
Search      
Javascript
Volunteer
Answers to thousands of questions
 Home · More Javascript Questions · Answer Library  · Encyclopedia ·
More Javascript Answers
Question Library

Ask a question about Javascript
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Randy L. Taylor
Expertise
I can answer advanced questions concerning most aspects of web programming including HTML, DHTML, DOM, JavaScript, Cookies, Internet Explorer, and CSSs. I can answer basic questions concerning XML and ActiveX. I can also answer questions concerning Regular Expressions, logical design algorithms, and Object Oriented Programming.

Experience

Past/Present clients
Upp Business Systems, LLC
Headquarters Standard Systems Group, USAF

 
   

You are here:  Experts > Computing/Technology > Focus on JavaScript > Javascript > Detect Window Resize

Javascript - Detect Window Resize


Expert: Randy L. Taylor - 3/24/2004

Question
Hi. How do I detect if the browser window has been resized? I placed this code in my body tag:

onResize="alert('Thanks For Resizing');"

but doesn't work. I'm using IE6 on WinXP PC. Any suggestions? I appreciate your help.

Thanks in advance,
Mark

Answer
Hi there Mark,

To be honest, I'm not sure why that's not working for you.  When I try that - it works fine for me and I get the alert.  I am also using IE6 on WinXP.  My body tag looks like this:

<body onResize="alert('body resize');">


There is another way to do the same thing, and perhaps that method may work for you when this one doesn't for some reason.  Put a script tag in your page like this:

<script language="Javascript">
document.body.onresize = function (){
 alert("Thanks for resizing!");
}
</script>

That method also works for me, and it may work for you too.

take care,
Randy L. Taylor

View Follow-Ups    Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.