Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

addEventListener for the onresize event

5 views
Skip to first unread message

McGurk

unread,
Sep 29, 2006, 4:29:50 PM9/29/06
to
Is there a reason why this isn't working in Moz?

function SizeAll(){alert('foo!');}
function attachEvent(){
if(document.body.addEventListener)
{
document.body.addEventListener('resize',SizeAll,false);
}
else if(document.body.onresize)
{
document.body.onresize= SizeAll;
}
else if (document.body.attachEvent)
{
document.body.attachEvent('onresize',SizeAll);
}
}

changing 'resize' to 'onresize' doesn't work either. This works in IE
and Opera. TIA.

Martin Honnen

unread,
Sep 30, 2006, 8:54:50 AM9/30/06
to
McGurk wrote:

> Is there a reason why this isn't working in Moz?
>
> function SizeAll(){alert('foo!');}
> function attachEvent(){
> if(document.body.addEventListener)
> {
> document.body.addEventListener('resize',SizeAll,false);
> }

The window is being resized so use e.g.
if (typeof window.addEventListener != 'undefined') {
window.addEventListener(
'resize',
SizeAll,
false
);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

0 new messages