Home > Web Front-end > JS Tutorial > body text

How to achieve the flashing effect of web page title

醉折花枝作酒筹
Release: 2021-04-21 09:43:45
forward
2882 people have browsed it

This article will give you a detailed introduction to the method of achieving the flashing effect of web page titles. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to achieve the flashing effect of web page title

Code

// 获取当前网页标题
    // console.log(document.title);
    // document.title = '快点 打开'

    // 如果状态的数量是固定的一定要想到两个固定的东西
    // 1. 取余
    // 2. switch……case……

    // 1.定时器
    // 2.两个标题
    // 这里空格必须使用全角的空格 否则不会在标题中显示
    var title1 = '[   ]标题名';
    var title2 = '[新提醒]标题名';
    var i = 0;
    setInterval(function() {
        // 切换两个标题的显示
        // 判断
        if (i % 2 == 0) {
            document.title = title1;
        } else {
            document.title = title2;
        }
        i++;
    }, 500);
Copy after login

It should be noted that

  • cannot ignore the definition of i variable

  • You cannot use half-width spaces for spaces

[Recommended learning: javascript advanced tutorial

The above is the detailed content of How to achieve the flashing effect of web page title. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!