Forum Moderators: open

Message Too Old, No Replies

Text wink

In JavaScript, how?

         

romzinho2k7

7:13 am on Apr 16, 2006 (gmt 0)

10+ Year Member



Hey friends...

It would like to know if someone could help with a code in JavaScript. I have wanting to do a text ( link ) keep winking every 2 seconds, but do not be getting. I tried to search in the google, but did not find any script this way.

Will it it be what anybody could help?

Thank you very much to everybody.

Moby_Dim

5:44 pm on Apr 16, 2006 (gmt 0)

10+ Year Member



It's easy enough (but doubt whether it's really useful ;) Read about js timers/setInterval()... and you'll understand and find the way.

romzinho2k7

9:01 pm on Apr 16, 2006 (gmt 0)

10+ Year Member



OK.... It read about what you said ;-) Managed to do in parts script. I did one and worked and another not.

It thus works: ( It winks white and red )
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<html>

<head><script LANGUAGE="JAVASCRIPT">
<!--
state=0
function winks(){
if(state==0){
document.fgColor="#FF0000"
state=1
}else{
document.fgColor="#FFFFFF"
state=0
}
setTimeout("winks()",500)
}

//-->
</script>

<title>Wink - Wink</title>
</head>

<body onLoad="winks()">
<p>WINK</p>
</body>
</html>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

But I did not want to use onLoad, it wanted to do that for iD. I did this way:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<html>

<head><script LANGUAGE="JAVASCRIPT">
<!--
local_spans = document.getElementById("local");
spans = local_spans.getElementsByTagName("td");

if(spans.id == "wink"){
state=0
function winks(){
if(state==0){
document.fgColor="#FF0000"
state=1
}else{
document.fgColor="#FFFFFF"
state=0
}
setTimeout("winks()",500)
}
}

//-->
</script>

<title>Wink - Wink</title>
</head>

<body>
<table>
<tr>
<td id="wink">WINK</td>
</tr>
</table>
</body>
</html>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

But thus does not work. Where that am I being mistaken?

Thanks.

Moby_Dim

5:48 am on Apr 17, 2006 (gmt 0)

10+ Year Member



No onload? Then you have to trigger the process of winking somehow. Put the script in the end of the page. Something like this :

<html>

<head><script LANGUAGE="JAVASCRIPT">
<!--

var state = 0;

function winks(){
var wi = document.getElementById('wink');
if(state==0){
wi.style.color = '#f00';
wi.style.fontWeight = 'bold';
state=1
}else{
wi.style.color = '#000';
wi.style.fontWeight = 'normal';
state=0
}
setTimeout("winks()",500)
}
//-->
</script>

<title>Wink - Wink</title>
</head>

<body>
<table>
<tr><td id="wink">WINK</td></tr>
<tr><td id="nowink">noWINK</td></tr>
</table>
<script language="JavaScript" type="text/javascript">
winks();
</script>
</body>
</html>

romzinho2k7

9:22 pm on Apr 17, 2006 (gmt 0)

10+ Year Member



Thank you very much! =)

It worked perfectly.