Closed
Bug 83981
Opened 24 years ago
Closed 24 years ago
document.getElementById([link]).href = [url]; doesn't respond
Categories
(Core :: DOM: CSS Object Model, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla0.9.4
People
(Reporter: martin.hofer, Assigned: jst)
References
()
Details
Attachments
(2 files)
629 bytes,
text/html
|
Details | |
1002 bytes,
patch
|
Details | Diff | Splinter Review |
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; 0.8) Gecko/20010215
BuildID: 2001021508
I have a web page that ist formatted by a .css file. Now I am trying to assign
an new "skin" to the page by setting the href of the link to the .css file:
document.getElementById('csslink').href = 'test.css';
This works (I know because document.getElementById('sty').href is set correctly
to the new file name, automatically extended by the complete path), but there
are no visible results. Even forcing the browser to re-render the page by
assigning new styles to elements of the page doesn't help.
Reproducible: Always
Steps to Reproduce:
I have prepared a page to demonstrate the problem:
1. Go to http://www.internetfabrik.de/martin/mozillabug/test.html
2. Click on the link 'test'.
Try it with IE 5.5 (5.0 won't work either), it works there (via document.all of
course)
Actual Results: The page doesn't change.
Expected Results: The page should change, according to the new style sheet.
I'm not sure if this meets your definition of a bug, but I think if it is
possible to set this value, there should be a result ;-)
If you don't want this to be possible, you should consider making this variable
read-only.
Comment 1•24 years ago
|
||
In a debug Mozilla build, I see this error when I perform the test:
Error loading URL javascript:test() : 2152924149
I don't know if that is relevant or not.
This is a browser issue, not JavaScript Engine. Reassigning to
Style System component for further triage; not sure if this is
a duplicate of an existing bug -
Here is the HTML of the testcase:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Unbenannt</title>
<link rel=stylesheet type="text/css" href="formats.css" ID="csslink">
<SCRIPT LANGUAGE="JAVASCRIPT">
function test() {
if (document.all) {
document.all.sty.href = 'test.css';
} else if (document.getElementById) {
alert('BEFORE:\ndocument.getElementById(\'csslink\').href is now\n' +
document.getElementById('csslink').href)
alert('ACTION:\nsetting document.getElementById(\'csslink\').href to
\'test.css\'\n')
document.getElementById('csslink').href = 'test.css';
alert('AFTER:\ndocument.getElementById(\'csslink\').href has been changed
to\n' + document.getElementById('csslink').href + '\nbut the page didn\'t
change!')
}
}
</SCRIPT>
</head>
<body ID="b">
<A HREF="javascript:test()">test</A>
</body>
</html>
Assignee: rogerl → pierre
Status: UNCONFIRMED → NEW
Component: Javascript Engine → Style System
Ever confirmed: true
QA Contact: pschwartau → ian
![]() |
||
Comment 2•24 years ago
|
||
This looks really familiar. I'm almost certain it's a dup.
Whiteboard: DUPEME
Comment 5•24 years ago
|
||
For reference, here is H-J's HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>sm83981-0.html</title>
<link rel=stylesheet type="text/css"
href="http://www.internetfabrik.de/martin/mozillabug/formats.css" ID="csslink">
<script type="application/x-javascript">
<!--
function test() {
document.getElementById('csslink').setAttribute("href","http://www.internetfabri
k.de/martin/mozillabug/test.css");
}
//-->
</script>
</head>
<body ID="b">
<a HREF="javascript:test()">test</a>
</body>
</html>
Updated•24 years ago
|
Assignee: pierre → peterv
Component: Style System → DOM Style
Whiteboard: DUPEME
Comment 6•24 years ago
|
||
Dynamic changes of linked stylesheets was implemented by peterv in bug 7515 but
I'm not marking this bug as dup yet because we need to answer the following
question...
This line works:
document.getElementById('csslink').setAttribute("href","test.css");
This line does not work:
document.getElementById('csslink').href = 'test.css';
Is it normal?
Comment 7•24 years ago
|
||
martin.hofer: note that your build (2001021508) doesn't have the fix for bug 7515
which was checked in on May 18th.
Updated•24 years ago
|
Priority: -- → P3
Target Milestone: --- → mozilla0.9.4
Comment 9•24 years ago
|
||
Comment 10•24 years ago
|
||
The fix seems to be in contradiction with the comment on line #93 which says:
"nsGenericHTMLLeafElement::SetAttribute() calls SetAttribute() which ends up
calling UpdateStyleSheet so we don't call UpdateStyleSheet here ourselves."
If the comment is wrong or doesn't apply to the proposed fix, then r=pierre.
Comment 11•24 years ago
|
||
Well, we have too many SetAttribute functions ;).
nsGenericHTMLLeafElement::SetAttribute(nsINodeInfo* aNodeInfo, ...) calls
nsHTMLLinkElement::SetAttribute(PRInt32 aNameSpaceID, ...) which calls
UpdateStyleSheet(). This function calls
nsGenericHTMLLeafElement::SetAttribute(PRInt32 aNameSpaceID, ...), not
nsHTMLLinkElement::SetAttribute(PRInt32 aNameSpaceID, ...). Are you confused
yet? I could change the comment to
// nsGenericHTMLLeafElement::SetAttribute(nsINodeInfo* aNodeInfo,
// const nsAReadableString& aValue,
// PRBool aNotify)
//
// calls
//
// nsHTMLLinkElement::SetAttribute(PRInt32 aNameSpaceID,
// nsIAtom* aName,
// const nsAReadableString& aValue,
// PRBool aNotify)
//
// which ends up calling UpdateStyleSheet so we don't call UpdateStyleSheet
// here ourselves.
Comment 12•24 years ago
|
||
r=pierre with updated comment.
jst, please s/r
Assignee | ||
Comment 13•24 years ago
|
||
sr=jst
Comment 14•24 years ago
|
||
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 15•24 years ago
|
||
I don't see the testcase working at all with build 2001081716 on Win2k (SP2).
It works just fine with IE 5.5 (SP1). However, the link given in the URL works
just fine. Here's the difference:
The link in the URL field uses (works):
document.getElementById('csslink').href='http://www.internetfabrik.de/martin/mozillabug/test.css';
The testcase uses (dosn't work):
document.getElementById('csslink').setAttribute('href','http://www.internetfabrik.de/martin/mozillabug/test.css');
Note: This seems to be exactly opposite of the behavior that Pierre noted in
his 7/20 comment.
Reopening this bug for the problem with setAttribute not working any more.
Jake
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 16•24 years ago
|
||
Fall-out from the SetAttribute/SetAttr renaming. Jst wants this.
Assignee: peterv → jst
Status: REOPENED → NEW
Comment 17•24 years ago
|
||
..and fixed it.
Status: NEW → RESOLVED
Closed: 24 years ago → 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•