Home  >  Article  >  Web Front-end  >  Title bar new message flashing prompt effect implemented by js_javascript skills

Title bar new message flashing prompt effect implemented by js_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:45:371685browse

This new message prompt effect is used in the company’s projects, and is mainly used to remind users that there are new messages. The specific implementation code is as follows:

Copy code The code is as follows:

var newMessageRemind = {
_step: 0,
_title: document.title,
_timer: null,
//Show new message prompt
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 (new MessageRemind._step == 1) {
                         document.title = "【  】" temps
                                                                                                                                                                         },
        800); ;
document.title = newMessageRemind._title;
//Write Cookie operation here
}

};



Call to display new message reminder: newMessageRemind.show();

Call to cancel new message reminder: newMessageRemind.clear();

Another: This simple code will cause such a problem:
That is, when you open many pages of a site, if there is new news, all the pages will keep flashing. When you Other pages will still prompt after viewing the message.

Our company solves the problem by using cookies. When viewing new messages, all pages with flashing titles will cancel the prompt.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn