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
https://forums.phpfreaks.com/topic/154954-stop-onmouseover/
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
https://forums.phpfreaks.com/topic/154954-stop-onmouseover/#findComment-815114
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.