jquery to implement new message flashing caption Hint method _jquery

Source: Internet
Author: User

The example in this article describes the method for jquery to implement the flashing caption hints for new messages. Share to everyone for your reference. Specifically as follows:

This code can be used to display the hint information flashing in the title bar.

1. jquery Plugin Style code

;(function ($) {
  $.extend ({
    /**
     * Call method: var Timerarr = $.blinktitle.show ();
     *     $.blinktitle.clear (timerarr);
     * * *
    blinktitle: {
      show:function () {//* * * * * * When new messages are blinking at title to prompt
        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};
        }
        ; return [timer, _title];
      },
      /**
       * @param timerarr[0], timer tag
       * @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);

2. The method of invocation is as follows:

JQuery (function ($) {
  var Timerarr = $.blinktitle.show ();
  settimeout (function () {//Here is automatically disappeared after a certain period of time
    $.blinktitle.clear (Timerarr);
  }, 10000);
  If the human operation disappears, simply call it: $.blinktitle.clear (Timerarr);
};

Full instance code click here to download the site.

I hope this article will help you with your jquery programming.

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.