JS implementation of the title bar new message flashing hint effect _javascript tips

Source: Internet
Author: User

The effect of this new message hint is used in the company's project, which is mainly used to prompt the user for new messages. The specific implementation code is as follows:

Copy Code code as follows:

var newmessageremind = {
_step:0,
_title:document.title,
_timer:null,
Show new message Prompts
Show:function () {
var temps = newmessageremind._title.replace ("" "" "" "). Replace (" "New Message" "," ");
Newmessageremind._timer = settimeout (function () {
Newmessageremind.show ();
Write Cookie operation here
newmessageremind._step++;
if (Newmessageremind._step = = 3) {
Newmessageremind._step = 1
};
if (Newmessageremind._step = = 1) {
Document.title = "" "+ Temps
};
if (Newmessageremind._step = = 2) {
Document.title = "" New Message "" + Temps
};
},
800);
return [Newmessageremind._timer, Newmessageremind._title];
},
Cancel New Message prompt
Clear:function () {
Cleartimeout (Newmessageremind._timer);
Document.title = Newmessageremind._title;
Write Cookie operation here
}

};

The call displays a new message prompt: Newmessageremind.show ();

Call cancels new message prompt: Newmessageremind.clear ();


Another: Simple this code will appear this problem:
When you open a site many pages, such as a new message, then all the pages will not stop flashing, when you view the message, other pages will still be prompted.

Our company is solved by the use of cookies, when the new message, all the flashing banner page will be canceled all prompts.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.