Problem getting onresize to work

D

Darrel Yurychuk

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() {
alert ('resize_func has been called');
}
window.onresize = resize_func();
</script>
</head>
<body>
<p>Just Some Text</p>
</body>

When I load this page in firefox (1.0.6). I get the alert box that pops
up on initial load, but any subsequent resizing of the window fails to
trigger the event. It's probably something really simple, but so far
I'm stumped. Any help would be greatly appreciated. Thanks
 
L

Lee

Darrel Yurychuk said:
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() {
alert ('resize_func has been called');
}
window.onresize = resize_func();

That last line executes resize_func() and assigns the return value
(void, in this case) to window.onresize. If you want to assign a
reference to your function to window.onresize, leave off the parentheses:

window.onresize=resize_func;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top