Jump to content

onmouseout problem - multiple divs in one area


edg322

Recommended Posts

I've got what at first would seem to be a simple issue to resolve.  I have a js timer that changes content visibility every couple of seconds, all within the same area in a page.  To change the visibility, the javascript simply sets style:visible to one area of content, and sets the rest to hidden.  To accomplish that, I had to have several div tags.  The javascript then sets each div tag to visible or hidden accordingly.  What I want to have happen next is this - when user moves the mouse over that area, the js timer stops, and the current content remains visible, until the click one of a few tabs I have in the top portion of the area, or until they mouseout.  When the user mouses out, the timer should kick in again.

So I have the following code:

[code]<div id="MyMainAreaDiv" onmouseover="javascript:StopTheTimer()" onmouseout="javascript:StartTheTimer()">
<div id="content1" style=(visible or hidden depending on js timer)</div>
<div id="content2" style=(visible or hidden depending on js timer)</div>
<div id="content3" style=(visible or hidden depending on js timer)</div>
</div> <!-- this div closes "MyMainAreaDiv" -->[/code]

This works fine, except for one thing - when the mouse is inside the area, every time it moves one pixel, it thinks it is mousing out of 'MyMainAreaDiv' and mousing back over, again and again, because content1 content2 and content3 all take up exactly the same area within the page.  So when you mouse over the area, it does stop if you stop moving the mouse.  But move the mouse around some within the area, and the content visibility changes very rapidly.  Hopefully I explained it well and left enough code.  Any suggestions appreciated.  I am thinking I may need to write some event listener...  I tried a delay on my javascript StartTheTimer, like a pause of a couple seconds, but that caused all kinds of odd behaviour with the actual js timer functionality ...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.