Forum Moderators: open

Message Too Old, No Replies

Blinking Text - How to Do it

But only for a few seconds?

         

Nick_W

8:44 pm on Jul 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

No, I've not lost my mind, I really do want to know how to make some text blink but only for a few seconds to draw a users attention to somthing.

It's for a 'my favorites' type thingy, when the bookmark a page of the site, they will have a link to 'view their favorites' and the as the link is not normally part of the page navigation I'd like to draw attention to it.

Do I have to use JS to achieve this? - I know of the text-decoration: blink jobbie but is there a way to control the amount of time it blinks that I'm not aware of?

Opinions on whether this is valuable would also be welcome though I'll probably do it anyway ;)

Many thanks..

Nick

drbrain

9:02 pm on Jul 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'd have to use a bit of javascript to turn off the blinking, I would use the text-decoration [w3.org] property.

Interestingly enough, I found a use for marquee in a web app. Its a web-controlled MP3 player that scrolls the title so the app can fit in a popup of specific width. (Yes that's two 'web sins'.)


<script type="text/javascript">
function init() {
setTimeout("stopBlink", 5000); // 5 seconds
}

function stopBlink() {
document.getElementById("blink").style.textDecoration = "none";
}
</script>

<a id="blink" style="text-decoration:blink" href="favorites.html">My Favorites</a>

But it does not work! It blinks eternally, mocking me! (I never did look too deeply into this JS+CSS stuff.)

claus

9:44 pm on Jul 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This one does the trick:

<script type="text/javascript" language="JavaScript">
<!--
function blink(){
blink_x = 1
blink_y = 1
ticToc();
}

function ticToc(){
if(blink_x==1){
blink_x=0;
blink_y++;
document.getElementById("blink").style.visibility='visible';
}else {
blink_x=1;
blink_y++;
document.getElementById("blink").style.visibility='hidden';
}
if (blink_y < 20) {setTimeout('ticToc()', 100);}
}
-->
</script>

Manipulate the values 20 and 100 in the bottom line until they suit you. I assume the thingy that must blink has an ID="blink". Call the script by:

<body onLoad="blink();">

/claus

<added>

-valuable? Yes, with the time limit. At least i found it valuable enough to write it. It's for my company page that has two languages. The default language is English, but as i live in Denmark, my Danish visitors need to be made aware of the version in Danish.
</added>

Nick_W

6:09 am on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks very much guys. That's just what I needed, a couple of new toys to play with ;)

Nick

Nick_W

4:07 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, as Opera (and I assume others) do not honor the blink property (which they are allowed to do according to w3c) I decieded to go with the visibility method.

I've got it running very smoothly, thanks.

What I'm now doing is this:

  1. User clicks 'bookmark' link and is sent to /bookmark.php
  2. Where a 10second cookie is set with PHP called 'blink' and the actual bookmarking happens too of course.
  3. They are then redirected back to the refering page where it checks to see if a cookie exists called 'blink'.
  4. If so, then the template is loaded with the onLoad in the body tag and those values set to 6 and 500 which makes the 'view bookmarks' link blink slowly 3 times
  5. If they are just skimming through pages, the 'view bookmarks' link is still there but does not blink

Very neat. Thanks again!

Nick

henry0

12:40 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thinlk about it
many will consider the <blink> as NO NO and clicl away

rogerd

2:34 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Nick_W, I think you are breaking new ground in the field of blinking text. :) Your name will be revered by blinking text advocates everywhere... Perhaps this will become known as the Nick_W hack. ;)

Did you consider an animated gif and just looping it a few times?

Nick_W

2:43 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>NO NO

Nah.... it only blinks twice after a very specific action to alert you to the fact that you have 'bookmarks'. It's rather useful actually but I'll update this thread when it goes live and I get complaints ;)

>animated gif
Never even crossed my mind. Doh!

An elegant solution but I like the text version better ;-)

Nick

ShawnR

3:12 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"...only blinks twice after a very specific action ..."

What sort of action? For example, (just thinking from a purist perspective) you can get away without javascript by changing the CSS attrib of what you want to make blink, when the mouse hovers over something else.

Shawn

Nick_W

3:27 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>action

When a users 'bookmarks' a product

>CSS

Yep, first port of call (see msg1-5) - Opera does not support this attribute and I want it to work on as much as possible....

Nick

claus

10:28 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



just dropped by to say this is a worthy cause for a blink imho (and those are rarely found) - the cookie thing is very neat indeed, perhaps i can use this method as well to let the number of blinks approach zero for repeat visitors to my page - no need to bother them unnecessarily ;)

/claus

mat_bastian

10:37 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



<blink>hello</blink>

might be depricated and it's definately annoying but it works.

SlowMove

10:42 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or an animated gif that looks like text :)

rogerd

2:28 am on Aug 1, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



This thread highlights a serious shortcoming here at WebmasterWorld - the lack of a functional "blink" style code for the forum. Nick, perhaps you'd like to consult with Brett on how to implement this so that we can all share the joys of blinking. ;)

DrDoc

2:41 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have to say that I think this particular situation is a very valid excuse to implement blinking text.

Tools like blinking text, scrolling marquees, popup windows - all considered evil - can be very helpful, even the only right tool, depending on the situation.

And, it's not like it blinks forever, just flashes two times to tell the visitor that he has a new link. Very clever, Nick!

DrDoc

2:42 pm on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



functional "blink" style code for the forum

I don't believe I have that phrase in my dictionary ;)

NickH

4:17 pm on Aug 2, 2003 (gmt 0)

10+ Year Member



Bear in mind that causing text to blink, even temporarily, could mean your page does not conform to WAI-AA (priority 2 items) guidelines.

Nick

7.2 Until user agents allow users to control blinking, avoid causing content to blink (i.e., change presentation at a regular rate, such as turning on and off). [Priority 2]

DrDoc

8:15 am on Aug 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See, using JavaScript (or an animated GIF) can be turned off in basically all browsers. So, I think Nick's clear ;)