Closed
Bug 271996
Opened 20 years ago
Closed 20 years ago
[FIXr]Setting page title in javascript does not work if <title></title> tags are omitted or empty.
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla1.8beta1
People
(Reporter: futhark77, Assigned: bzbarsky)
Details
(Keywords: testcase)
Attachments
(2 files)
183 bytes,
text/html
|
Details | |
9.17 KB,
patch
|
sicking
:
review+
neil
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
The javascript statement document.title = "new title" does not work if your page
does not have the <title> tags at all or if you set an empty title in html like
<title></title>.
I set my page title as empty in my php program, and change it later on. The
javascript to do that does not work in Firefox but it does in Konq.
Workaround is to declare the title as <title> </title>
Reproducible: Always
Steps to Reproduce:
1. I will attach a sample html. Load it in Firefox. Even though javascript sets
the title as "New title", you won't see that.
2. Open the same page in Konq. The title will be set to "New title" as expected.
3. Modify the html. Type any char between <title></title> (or even a fancy
). Reload the page in Firefox. Title will be set to to "New title" as
expected.
Expected Results:
Firefox should not bother with the default value of the page title. It should
always accept it be changed through the document.title property.
Same in Mozilla Suite 1.8a5 on WinNT4. Works in IE. I don't see an error in JS
console.
OS: Linux → All
Updated•20 years ago
|
Assignee: firefox → general
Component: General → DOM: HTML
OS: All → Linux
Product: Firefox → Core
QA Contact: firefox.general → ian
Version: unspecified → Trunk
Comment 3•20 years ago
|
||
confirmed with linux trunk 2004112905
![]() |
Assignee | |
Comment 4•20 years ago
|
||
This uses the actual document title to see whether we've set the title yet
instead of using the local content sink member.
Attachment #170367 -
Flags: superreview?(neil.parkwaycc.co.uk)
Attachment #170367 -
Flags: review?(bugmail)
![]() |
Assignee | |
Updated•20 years ago
|
Assignee: general → bzbarsky
Priority: -- → P2
Summary: Setting page title in javascript does not work if <title></title> tags are omitted or empty. → [FIX]Setting page title in javascript does not work if <title></title> tags are omitted or empty.
Target Milestone: --- → mozilla1.8beta
Comment on attachment 170367 [details] [diff] [review]
Patch
>+ if (mDocument->GetDocumentTitle().IsVoid()) {
>+ nsCOMPtr<nsIDOMNSDocument> domDoc(do_QueryInterface(mDocument));
>+ domDoc->SetTitle(EmptyString());
> }
This is unrelated to this bug of course, but that code looks ridiculous. Why do
we have to set the title to emptystring if it already is empty? (And through a
different interface nontheless)
Attachment #170367 -
Flags: review?(bugmail) → review+
![]() |
Assignee | |
Comment 6•20 years ago
|
||
Because SetTitle doesn't just set the member -- it notifies the docshell of the
new title and fires a DOM event on the title change... That allows the UI to
update the title it's displaying. Silly, but changing the way titles work
altogether is a story for another bug.
As for why there is not title setter on nsIDocument, I think that's because all
documents do expose SetTitle(nsAString) via nsIDOMNSDocument...
Comment 7•20 years ago
|
||
Comment on attachment 170367 [details] [diff] [review]
Patch
>- text->SetText(mTitle, PR_TRUE);
>+ text->SetText(title, PR_TRUE);
I was surprised to see that the text node is set to the trimmed text...
Attachment #170367 -
Flags: superreview?(neil.parkwaycc.co.uk) → superreview+
![]() |
Assignee | |
Updated•20 years ago
|
Summary: [FIX]Setting page title in javascript does not work if <title></title> tags are omitted or empty. → [FIXr]Setting page title in javascript does not work if <title></title> tags are omitted or empty.
![]() |
Assignee | |
Comment 8•20 years ago
|
||
Fixed for 1.8b
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•