Click to See Complete Forum and Search --> : XHTML Strict onresize


r_barlow
05-24-2006, 03:43 PM
Hey,

When I validate my XHTML strict page, it gives me an error saying that there is no attribute "onresize" on the code

<body onresize="javascript:moveLinks();">

Does anybody know a workaround? I can't find one anywhere.

the tree
05-24-2006, 03:52 PM
It's not so much a workaround as it is the right way to do it in the first place.<script type="text/javascript">
<![CDATA[
document.onresize = moveLinks();
]]>
</script>

r_barlow
05-24-2006, 04:34 PM
Thanks but that doesn't work in IE...

kenkam
05-24-2006, 10:11 PM
for IE, it's window.onresize

to do IE only execution, insert this


<!--[if IE]>
<script type="text/javascript">
<![CDATA[
window.onresize = moveLinks();
]]>
</script>
<![endif]-->

r_barlow
05-25-2006, 10:04 AM
That doesn't work either. It only executes once when the page is first opened.

Any other suggestions?

kenkam
05-25-2006, 10:12 AM
I DO apologise.


<!--[if IE]>
<script type="text/javascript">
<![CDATA[
window.onresize = moveLinks;
]]>
</script>
<![endif]-->


From Quirksmode (http://www.quirksmode.org/js/events_tradmod.html):

No brackets!

Please note that in the registration of an event handler you do not use brackets (). The onclick method expects to be assigned an entire function. If you’d do
element.onclick = doSomething();

the function would be executed and its result would be registered to onclick. This is not what we want, we want the function to be executed when the event takes place. In addition the function has usually been written to expect an event and if we’d execute it without any such context it would get terribly confused and produce JavaScript errors.


The same applies for the FF version.

r_barlow
05-26-2006, 10:19 AM
Thanks a lot... works great!!

kenkam
05-26-2006, 10:50 AM
My pleasure :D