Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  148] [ 1]  / answers: 1 / hits: 114723  / 13 Years ago, fri, february 10, 2012, 12:00:00

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



I use firefox and with



document.title 


I get extra - Mozilla Firefox to the end of the title. I know it would be easy to get rid of this by modifying string but if they change text, use different format etc or some other browser modifies this differently I have extra text there again.



So, is there any cross browser way to get the plain tag content with javascript? Jquery solution is ok.


More From » title

 Answers
3

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;

[#87552] Wednesday, February 8, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
noel

Total Points: 49
Total Questions: 90
Total Answers: 104

Location: Aland Islands
Member since Wed, Nov 17, 2021
3 Years ago
;