where to place browser event (resize/scroll) detection call

Posted by karl on Stack Overflow See other posts from Stack Overflow or by karl
Published on 2010-03-26T09:40:13Z Indexed on 2010/03/26 9:43 UTC
Read the original article Hit count: 144

Filed under:
|

I'm trying to alert a message when the browser is resized or scrolled. I'm detecting the 2 events in the body

<body onResize="doDisp();" onScroll="doDisp();" >

where doDisp is this inside the <script> tag

<script type="text/javascript">

  function doDisp(){
    alert("browser changing state");
  }

</script>

but isn't it bad practice to have javascript in the body tag? Is there a cross-browser way to keep all the javascript inside the <script> tags?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about best-practices