How to get current html page title with javascript

后端 未结 4 971
予麋鹿
予麋鹿 2020-12-03 06:17

I\'m trying to get the plain html page title with javascript.

I use firefox and with

document.title 

I get extra \"- Mozilla Firef

4条回答
  •  忘掉有多难
    2020-12-03 06:50

    One option from DOM directly:

    $(document).find("title").text();
    

    Tested only on chrome & IE9, but logically should work on all browsers.

    Or more generic

    var title = document.getElementsByTagName("title")[0].innerHTML;
    

提交回复
热议问题