New message blinking title hints JavaScript code

Source: Internet
Author: User
The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> flashing tips for new messages demo</title>

<body>
<p style= "Text-align:center;" > Please see the title of the page effect!
<br/> tip disappears after 10 seconds
</p>
<script type= "Text/javascript" src= ". /js/jquery-1.4.2.min.js "></script>
<script type= "Text/javascript" >
;(function ($) {

$.extend ({
/**
* Call Method: var Timerarr = $.blinktitle.show ();
* $.blinktitle.clear (Timerarr);
*/
Blinktitle: {
Show:function () {//When new messages are flashing in title
var step=0, _title = Document.title;

var timer = setinterval (function () {
step++;
if (step==3) {step=1};
if (step==1) {document.title= ' "' +_title};
if (step==2) {document.title= ' "new Message" ' +_title};
}, 500);

return [timer, _title];
},

/**
* @param timerarr[0], timer marker
* @param timerarr[1], initial title text content
*/
Clear:function (Timerarr) {//Remove flashing hint, restore initial title text
if (Timerarr) {
Clearinterval (Timerarr[0]);
Document.title = timerarr[1];
};
}
}
});
}) (JQuery);

JQuery (function ($) {
var Timerarr = $.blinktitle.show ();

settimeout (function () {//Here is automatically disappearing after a certain period of time
$.blinktitle.clear (Timerarr);
}, 10000);

If you think the operation disappears, just call it: $.blinktitle.clear (Timerarr);
});
</script>
</body>

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.