?
Solved

How to set <body> onresize event from Javascript code?

Posted on 2004-11-26
5
Medium Priority
?
5,534 Views
Last Modified: 2009-12-16
For some reason, I need to use Javascript to set the onresize event of the body tag on my web page. I tried to use this:

document.body.setAttribute("onresize", "alert('aaa');");

But it doesn't work. Does anybody know how to use Javascript to set onresize event of body tag?

Thanks a lot.
0
Comment
Question by:BruceCheng
  • 3
5 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 12683121
<body onresize = "alert('Resized')">
0
 
LVL 25

Expert Comment

by:archrajan
ID: 12683130
sorry that will nto work
0
 
LVL 25

Expert Comment

by:archrajan
ID: 12683138
<body  onResize="alert('HI')"">  this works
0
 
LVL 1

Author Comment

by:BruceCheng
ID: 12683230
I mean I need to set this "onresize" event javascript from Javascript code.

That <body> tag is from a global include file of my application. I cannot change the <body> tag at all.

Thanks.
0
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 500 total points
ID: 12683269
the body of the page you are trying to cahnge must be loaded before you can set the onresize.

<body>
   <script>document.body.onresize=function(){alert('hello')}</script>
</body>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question