blinking lines

H

Hugo

I am building a website. Now I want to put a couple of lines on my
page which I want to blink. <blink> is not supported for shapes/lines
and I want to decide myself if i want a line to blink. What do I mean:

button1.onclick{
line1.blink(??)}

button2.onclick{
line2.blink(??)}

button3.onclick{
stop blinking line1}

function blink(line){
blink every second (line.strokecolor = 'blue' and next time
line.strokecolor = 'red' for example)
}

Can it be done with setInterval or setTimeout? Mention that more than
one line has to blink.
Can anyone help me? Perhaps something with a timer or so. I am not
that experienced with java/programming. I realy appreciate your help.
 
P

Philip Ronan

Hugo said:
I am building a website. Now I want to put a couple of lines on my
page which I want to blink. <blink> is not supported for shapes/lines
and I want to decide myself if i want a line to blink.

HAS it NOT occurred TO you THAT your VISITORS might FIND blinking CONTENT
rather ANNOYING? you MIGHT be ABLE to DO this WITH animated GIF images, BUT
there IS nothing YOU can DO in CSS or HTML that WILL achieve THIS effect.

IF you WANT a PROFESSIONAL-looking SITE, then DON'T make THINGS blink. IT
looks REALLY stupid.
 
Z

Zifud

Hugo said:
I am building a website. Now I want to put a couple of lines on my
page which I want to blink. <blink> is not supported for shapes/lines
and I want to decide myself if i want a line to blink. What do I mean:

Don't tell me, you're doing a major in psychology and want to see if you
can give your users epileptic fits?

Please don't do this, it's silly.

Zif.
 
L

Lee

Hugo said:
I am building a website. Now I want to put a couple of lines on my
page which I want to blink. <blink> is not supported for shapes/lines
and I want to decide myself if i want a line to blink. What do I mean:

button1.onclick{
line1.blink(??)}

button2.onclick{
line2.blink(??)}

button3.onclick{
stop blinking line1}

function blink(line){
blink every second (line.strokecolor = 'blue' and next time
line.strokecolor = 'red' for example)
}

Can it be done with setInterval or setTimeout? Mention that more than
one line has to blink.
Can anyone help me? Perhaps something with a timer or so. I am not
that experienced with java/programming. I realy appreciate your help.


The following example stores the timer, colors, and state as
attributes of the span of text that's blinking, so they can
all blink independently. Note that it assumes that the client
browser supports getElementById and setting style.color:



<html>
<head>
<title>blink</title>
<script type="text/javascript">
function startBlink(id,onColor,offColor) {
var text=document.getElementById(id);
text.blinkColorOn=onColor;
text.blinkColorOff=offColor;
text.blinkState=false;
text.blinkTimer=setInterval("blink('"+id+"')",500);
}
function stopBlink(id,color) {
var text=document.getElementById(id);
clearInterval(text.blinkTimer);
text.style.color=color;
}
function blink(id){
var text=document.getElementById(id);
text.style.color=text.blinkState?text.blinkColorOn:text.blinkColorOff;
text.blinkState=!text.blinkState;
}
</script>
</head>
<body>
<p>
This is some sample text.<br>
<span id="b1">This line will start to blink if you click B1</span></br>
This line is just normal text.<br>
<span id="b2">This line will start to blink if you click B2</span></br>
</p>
<button onclick="startBlink('b1','red','blue')">B1</button><br>
stop all blinking</button>
</body>
</html>
 
L

Lee

Zifud said:
Don't tell me, you're doing a major in psychology and want to see if you
can give your users epileptic fits?

Please don't do this, it's silly.

It's silly to make lines blink constantly.
There are reasonable applications for lines that blink
a few times and then stop.
 
R

Robert

I am building a website. Now I want to put a couple of lines on my
page which I want to blink. <blink> is not supported for shapes/lines
and I want to decide myself if i want a line to blink. What do I mean:
Can it be done with setInterval or setTimeout? Mention that more than
one line has to blink.
Can anyone help me? Perhaps something with a timer or so. I am not
that experienced with java/programming. I realy appreciate your help.

Be careful with blinking. Blinking is a good way to scare people away
from your site.

You can use the style visibility attribute to hide things in the
window. By hiding and making the thing visible under the control of a
timer, you could simulate blinking.

Here is an example that uses style visibility.

<http://groups.google.com/[email protected]&rnum=1>
 
H

Hugo

i know that it is really irritating to use blinking lines and it isn't
for my homepage. I don't even think about it to use it for visitors.
The site I am making is for a small factory with a little Programmable
Logic Control. The website contains all pipelines of the factory. when
an alarm occurs in a pipeline, the pipeline has to blink. So, don't
just scream that blinking is irritating, that is so easy. But okay,
there where also people who want to help me. I know it can be done by
the visibility element, but I don't know how to use ONE timer and ONE
function with MULTIPLE lines. I hope somebody can help me with this
problem.

Greetings
Hugovic
 
F

Fred Oz

Hugo wrote:
[snip]
there where also people who want to help me. I know it can be done by
the visibility element, but I don't know how to use ONE timer and ONE
function with MULTIPLE lines. I hope somebody can help me with this
problem.

Greetings
Hugovic

Ah, always good to explain your actual problem, it makes life easier
for those who would help.

Lee has provided a solution above, though if you click the button more
than once the "stop blinking" function doesn't work properly. If you
are controlling the blink/don't blink programmatically, that may not
bother you.

Is it what you want?

Fred.
 
L

Lee

Fred Oz said:
Hugo wrote:
[snip]
there where also people who want to help me. I know it can be done by
the visibility element, but I don't know how to use ONE timer and ONE
function with MULTIPLE lines. I hope somebody can help me with this
problem.

Greetings
Hugovic

Ah, always good to explain your actual problem, it makes life easier
for those who would help.

Lee has provided a solution above, though if you click the button more
than once the "stop blinking" function doesn't work properly.

Yes. As soon as I posted it, I realized that the "stop blinking"
function should have some error checking to ensure that there is
an active timer to be cleared. I had to leave, and walked away
feeling sure that somebody would post the correction. I never
thought about it again until now.

function stopBlink(id,color) {
var text=document.getElementById(id);
if(text.blinkTimer){
clearInterval(text.blinkTimer);
text.style.color=color;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,434
Latest member
TobiasLoan

Latest Threads

Top