如果 document.title 不存在,如何获取页面标题名称

How to fetch page title name if document.title is not present

本文关键字:获取 标题 title document 不存在 何获取 如果      更新时间:2023-09-26

我想获取页面标题名称,但 document.title 不存在。而不是 document.title,逻辑写在下面:-

<title ng-bind="page.title()" class="ng-binding"></title>

我想使用javascript来获取页面标题。

。但文档标题不存在

一旦 Angular 更新了 title 元素,document.title应该有更新的版本。如果没有,则某处出了问题。

但:

我想使用javascript来获取页面标题。

大概你可以从代码中的page.title()中获取它。当您将其提供给Angular时。

但:

如果你真的需要从 DOM 获取它,你可以,但你不应该这样做。方法如下:

var title = document.querySelector("title").innerHTML;