#5881 closed bug (duplicate)
document.title needs special handling in Internet Explorer
Reported by: | hjess | Owned by: | john |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | core | Version: | 1.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In IE (versions 6, 7 & 8 on my PC); a few issues:
jQuery('title').html() returns the title (== document.title)
jQuery('title').text() is empty
jQuery('title').text('new title')
and
jQuery('title').html('new title') both raise an error:
Error: Unexpected call to method or property access.
These all work in Firefox (I'm using 3.5.7). Finally, these work better in IE, but still not quite right :(
jQuery('title').attr('text') returns document.title
jQuery('title').attr('text','new title') sets document.title properly. However, the title displayed in the browser chrome reflects the new title only in IE6. In IE7/IE8, even though the value of document.title matches the title element's 'text' attribute, the browser chrome changes only when you set document.title.
Change History (8)
comment:1 follow-up: 2 Changed 13 years ago by
comment:2 Changed 13 years ago by
Replying to dmethvin:
Using the
document.title
property is the simple cross-browser way to set or retrieve the document title. IE just doesn't want to play right.
Agreed -- but we've progressed to the point where developers would rather use jQuery access to elements rather than their direct DOM0 counterparts -- I've seen code like this:
function getById(id) {return jQuery('#'+id)[0]}
So, given that, it would be nice if jQuery supported IE's weirdness.
comment:3 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
The correct way to set the title is to set document.title
. Manipulating the DOM is incredibly slow and is very much the wrong way to do this.
comment:4 Changed 12 years ago by
I've been trying a few things, what works best is indeed the document.title property. However, if you want to use as much JQ as you can, I found that
$("title").innerHTML = $("title").attr("text", "New title");
works on IE8. A pointless workaround, if you ask me.
If anyone has a better idea...
comment:5 Changed 12 years ago by
Component: | selector → core |
---|---|
Milestone: | 1.4.1 |
Priority: | major → low |
Resolution: | wontfix |
Status: | closed → reopened |
comment:6 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Using the
document.title
property is the simple cross-browser way to set or retrieve the document title. IE just doesn't want to play right.