JS function in body tag problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

    #1

    JS function in body tag problem

    I have the following in my page body tag:

    <body onMouseMove="mo useCheck(event) ;">

    The problem is that the mouseCheck function cannot be loaded until the
    entire page is loaded so you get an JS error if you happen to move the mouse
    while the page is loading - "object not found". It then works fine once the
    page is loaded but the error is irritating to say the least.

    Is there some way I can assign the onMouseMoved with javascript only after
    the whole page has loaded?

    Thanks!


  • RobG

    #2
    Re: JS function in body tag problem

    Simon Wigzell wrote:[color=blue]
    > I have the following in my page body tag:
    >
    > <body onMouseMove="mo useCheck(event) ;">
    >
    > The problem is that the mouseCheck function cannot be loaded until the
    > entire page is loaded so you get an JS error if you happen to move the mouse
    > while the page is loading - "object not found". It then works fine once the
    > page is loaded but the error is irritating to say the least.
    >
    > Is there some way I can assign the onMouseMoved with javascript only after
    > the whole page has loaded?[/color]

    Assign the event using onload:

    <body onload="this.on mouseover = mouseCheck;">

    or you could use window.onload, it's up to you.

    --
    Rob

    Comment

    • Simon Wigzell

      #3
      Re: JS function in body tag problem

      Thanks! Works a treat.


      Comment

      Working...