# js代码实现网站页面标题自定义、滚动、闪烁显示

*Published:* 2023-11-16
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年11月16日，已超过 180天没有更新



**网站标题自定义并滚动：**

```
// JS 代码实现网站标题自定义
<script type="text/javascript">
var sTitle = "这句话是网站页面的标题"
function TitleMove(){
    sTitle = sTitle.substring(1, sTitle.length) + sTitle.substring(0, 1);
    document.title = sTitle;
    status = sTitle;
}
window.setInterval("TitleMove()", 100);
</script>
```

**网站标题滚动显示：**

```
// JS 代码实现网站标题滚动显示
<script type="text/javascript">
var msg = document.title;
msg = "………" + msg;pos = 0;
function scrollMSG() {
    document.title = msg.substring(pos, msg.length) + msg.substring(pos, 0);
    pos++;
    if (pos > msg.length) pos = 0
    window.setTimeout("scrollMSG()",200);
}
scrollMSG();
</script>
```

**网站标题闪烁显示：**

```
// JS 代码实现网站标题闪烁显示
<script type="text/javascript">
var step=0;
var ftitle=document.title; //获取网页标题
var space='';
for(var i=0;i<=ftitle.length;i++)space+='　'; //根据标题长度生产相应的空字符
function flash_title(){
    step++
    if (step==3) {step=1}
    if (step==1) {document.title=space}
    if (step==2) {document.title=ftitle}
    setTimeout("flash_title()",500);
}
flash_title();
</script>
```