Skip to main content

Bug Tracker

Side navigation

#5881 closed bug (duplicate)

Opened January 20, 2010 08:08PM UTC

Closed February 18, 2011 01:40PM UTC

Last modified March 14, 2012 12:55AM UTC

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.

Attachments (0)
Change History (8)

Changed January 20, 2010 10:00PM UTC by dmethvin comment:1

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.

Changed January 25, 2010 07:11PM UTC by hjess comment:2

Replying to [comment:1 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.

Changed November 01, 2010 05:34AM UTC by snover comment:3

resolution: → wontfix
status: newclosed

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.

Changed February 16, 2011 01:28PM UTC by anonymous comment:4

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...

Changed February 18, 2011 01:40PM UTC by jitter comment:5

component: selectorcore
milestone: 1.4.1
priority: majorlow
resolution: wontfix
status: closedreopened

Changed February 18, 2011 01:40PM UTC by jitter comment:6

resolution: → duplicate
status: reopenedclosed

Changed February 18, 2011 01:41PM UTC by jitter comment:7

Duplicate of #2755.