Javascript/Detect Window Resize

Advertisement


Iraj wrote at 2008-05-27 14:29:44
There is a matter of compatibilty, I tested this on IE and Mozilla. It worked fine on IE but it had showed result on mozilla so you have to play around with it to the it working for both.



After some research i found that this code works on mozilla



window.onresize = resize;



function resize()

{

alert("resize event detected!");

}


phkcorp2005 wrote at 2008-09-25 15:37:11
If you place this script in the <head> then will not work, but if place within the <body> then will work. Did verify both scenarios.


Greg wrote at 2010-01-14 17:49:36
The <body onResize=""> will work, but if you want to create an onResize trigger from within script, you need to use lowercase.



<script type="text/javascript">

   onresize=FunctionName;

</script>



Hope this helps.

- Greg.


Javascript

All Answers


Answers by Expert:


Ask Experts

Volunteer


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

©2012 About.com, a part of The New York Times Company. All rights reserved.