Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 7 years ago

#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 Changed 9 years ago by 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.

comment:2 in reply to:  1 Changed 9 years ago by hjess

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 8 years ago by snover

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.

comment:4 Changed 8 years ago by anonymous

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 8 years ago by jitter

Component: selectorcore
Milestone: 1.4.1
Priority: majorlow
Resolution: wontfix
Status: closedreopened

comment:6 Changed 8 years ago by jitter

Resolution: duplicate
Status: reopenedclosed

comment:7 Changed 8 years ago by jitter

Duplicate of #2755.

Note: See TracTickets for help on using tickets.