i've posted different html in my first post. 
the html i was trying is this./with js function for better reading 
Code:
<a class="pause" href="javascript:pause();" >Pause</a>
<script type="text/javascript" >
var paused=0;
function pause(){
var pauseNode=document.getElementsByClassName("pause")[0];
if(pauseNode.firstChild.nodeValue=="Pause"){
pauseNode.firstChild.nodeValue="Start";
that.paused=1;
clearInterval(that.loop);
}else if(pauseNode.firstChild.nodeValue=="Start"){
pauseNode.firstChild.nodeValue="Pause";
that.paused=0;
that.loop=setInterval(next,1000);
}
alert(that.paused); //outputs 0
/*Works
pauseNode.firstChild.nodeValue=="Pause";
pauseNode.firstChild.nodeValue="Start";
that.paused=1;
clearInterval(that.loop);
alert(that.paused); //outputs 1
*/
}
</script>
That html does not work with the first pause() function.
but placed inside a div element like this.
Code:
<div class="pause"><a href="javascript:pause();" >Pause</a></div>
can be reached in javascript like this.
Code:
function pause(){
var pauseNode=document.getElementsByClassName("pause")[0];
var a=document.getElementsByTagName("a")[1]; // second anchor element
if(a.firstChild.nodeValue=="Pause"){
a.firstChild.nodeValue="Start";
that.paused=1;
clearInterval(that.loop);
}else if(a.firstChild.nodeValue=="Start"){
a.firstChild.nodeValue="Pause";
that.paused=0;
that.loop=setInterval(next,1000);
}
}
and it works.
Thanks for you help.
Hope you have power,watter, and sewage soon. (our power supplier stops our power for 3 times in the last 3 days, probably not relatated but it sux.)
Bye.
Bookmarks