Jump to content

Stop onmouseover?


zeeshan_haider000

Recommended Posts

Hi, what can be done to this script so it stops on mouseover and resume back on mouseout (stop sliding text on mouse over and resume on mouseover)?

if (document.all || document.getElementById){ //if IE4 or NS6+
document.write('<style type="text/css">\n')
document.write('.dyncontent{display: none; width: auto; height: 60px;}\n')
document.write('</style>')
}

var curcontentindex=0
var messages=new Array()

function getElementByClass(classname){
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
messages[inc++]=alltags[i]
}
}

function rotatecontent(){
//get current message index (to show it):
curcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0
//get previous message index (to hide it):
prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
messages[prevcontentindex].style.display="none" //hide previous message
messages[curcontentindex].style.display="block" //show current message
}


window.onload=function(){
if (document.all || document.getElementById){
getElementByClass("dyncontent")
setInterval("rotatecontent()", 2000)
}
}

 

Also where can i find a script that will have the effects of like vertical sliding content? (update box/show recent things)?

Help would highly appreciated.

Regards,

ZEe

Link to comment
Share on other sites

personally... i would create a global boolian variable

var pause=false;

 

then in your rotating function

if(pause==true) return;

 

then you simply put an onmouseover/out pause=true/false;

 

this way it will start rotating onload(when you set that part of the program up) and when you mouseover it, it'll pause, and mouseout it'll resume where it left off... :)

 

this code may be rather raw... but i made something like this a LONG time ago... http://www.evergreengolfcentre.ca/

 

picture strip loads on default, scrolls when its done loading, pauses on mouseover, resumes on mouseout... seems like a ::) comparable idea to yours...

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.