Web Analytics Made Easy -
StatCounter onMouseOver problem when page loads - CodingForum

Announcement

Collapse
No announcement yet.

onMouseOver problem when page loads

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • onMouseOver problem when page loads

    I have the following:-

    <p align="center"><a href="#" onMouseOver="document.soundfile2.play()"><img src="ship11.gif" width="497" height="125" border="0"></a></p>

    This plays a gunshot sound when the mouse is positioned over the ship image.

    However, a small problem is that an unspecified JavaScript error is reported if when the page loads the mouse happens to be positioned at a place on the screen where the ship image will appear. That is, on_mouse_already_over. This does not
    affect the working, but I would like to tidy it up.

    Suggestions would be welcome, please. Changing the order of loading scripts etc. does not help.

    Is there any way of shifting the mouse coordinates to somewhere else on the screen?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #2
    I am happy to say that I have fixed the problem as follows:-

    <SCRIPT>
    var shotcount=0;
    function playgunshot() {
    if (shotcount > 1) {
    document.soundfile2.play();
    }
    shotcount ++;
    }
    </SCRIPT>

    <p align="center"><a href="#" onMouseOver="playgunshot()"><img src="ship11.gif" width="497" height="125" border="0"></a></p>

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment

    Working...
    X