我想获取页面标题名称,但 document.title 不存在。逻辑不是 document.title,而是写在下面:-
<title ng-bind="page.title()" class="ng-binding"></title>
我想使用javascript来获取页面标题。
最佳答案
...but document.title is not present
一旦 Angular 更新了 title
元素,document.title
就应该具有更新的版本。如果没有,则说明某个地方出了问题。
但是:
I want to use javascript to get page title.
大概您可以从代码中的 page.title()
获取它。当您将其提供给 Angular 时。
但是:
如果您确实需要从 DOM 获取它,您可以,但您不应该这样做。方法如下:
var title = document.querySelector("title").innerHTML;
关于javascript - 如果 document.title 不存在,如何获取页面标题名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29009915/