最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I prevent a page and tab's document.title from changing? - Stack Overflow

programmeradmin1浏览0评论

Some pages change their document.title, which appears in the page's tab, when certain events occur. It can be confusing to have a tab with ever-changing names, so I want to prevent it from changing. How to do this?

Some pages change their document.title, which appears in the page's tab, when certain events occur. It can be confusing to have a tab with ever-changing names, so I want to prevent it from changing. How to do this?

Share Improve this question asked Apr 20, 2016 at 10:26 Protector oneProtector one 7,3495 gold badges67 silver badges88 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 16

You can use javascript to define a property on the document object with name title and a non-functional setter.

Object.defineProperty(document, 'title', {
  set: function(){}
});

You could execute this in the Developer console, put it in the address bar as a single line prepended by "javascript:", or you could put it in a user script or extension if you want it to be executed every time.

发布评论

评论列表(0)

  1. 暂无评论