PDA

View Full Version : how to stop javascript function



Navarone
August 4th, 2008, 10:32 AM
How do I stop a javascript function from working. I have several menu items, when I rollover a menu item I want an image to partially slide in and when I rollout slide back off the screen. If I click the menu item, I wan the image to slide all the way in but I want to stop the rollout function from working for that particulare menu item until another menu item is clicked.

I am not sure how to set this up. I was trying to use a variable isOut to determine when to stop the rollOut function. If I rollover a menu item the value of isOut is set to True, if I click on the menu item, I check to see if its True and which menu item I am on, then continue the slide in, but then I don't want the mouseOut function to work for that menu element until I click on another menu item. I hope that makes sense.

Here is my code:


<script language="javascript" type="text/javascript">

var isOut =""

//slide in onClick
function slideIn(id){
//alert(isOut)
if(isOut == 'True' && id=='home'){
t1.continueTo(363,2);

// isOut = 'False'
// stop mouseOut function
}
}
/*
function slideOut(id){
t1 = new Tween(document.getElementById(id).style,'left',Twe en.elasticEaseOut,363,995,2,'px');
t1.start();
}
*/

//mouseOut
function bounceOut(id){
t1 = new Tween(document.getElementById(id).style,'left',Twe en.elasticEaseOut,830,995,1,'px');
t1.start();
}

//mouseOver
function bounceIn(id){
Show(id);
isOut = 'True'
//alert(isOut)
t1 = new Tween(document.getElementById(id).style,'left',Twe en.elasticEaseOut,995,830,1,'px');
t1.start();
}

//change background images onClick
function changeBg(id){
if(id=='home_btn'){
//alert('home')
document.getElementById('page_bg').style.backgroun dImage='url(images/home_bg.jpg)';
}

else if(id=='about_you'){
//alert('about_you')
document.getElementById('page_bg').style.backgroun dImage='url(images/aboutyou_bg.jpg)';
}
else if(id=='raise_bar'){
//alert('about_you')
document.getElementById('page_bg').style.backgroun dImage='url(images/raisebar_bg.jpg)';
}
}

</script>