Open
Bug 292792
Opened 19 years ago
Updated 2 years ago
JS/Dom: setting src-attribute for script tag is only possible once. Any further setting is ignored
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
NEW
People
(Reporter: schdeffan, Unassigned)
Details
Attachments
(1 file)
632 bytes,
application/x-zip-compressed
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.6) Gecko/20050321 Firefox/1.0.2 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.6) Gecko/20050321 Firefox/1.0.2 When trying to set the src-attribute of a given script-tag using JavaScript, it is only possible to set the attribute once. Any further attempt to set the attribute is ignored. One workaround is to replace the script tag by a newly created one using DOM. Reproducible: Always Steps to Reproduce: Create 3 files in the same folder, as shown below. Then chose the options from the listbox. test.html: <html> <body> <select onChange="setScript(this.options[this.selectedIndex].value)"> <option value="">Choose</option> <option value="sc1.js">Script 1</option> <option value="sc2.js">Script 2</option> </select> <div id="Test"></div> <script> function setScript(url) { document.getElementById("special").src = url; } </script> <script id="special"></script> </body> </html> sc1.js: document.getElementById("Test").innerHTML = "Script1"; sc2.js: document.getElementById("Test").innerHTML = "Script2"; Actual Results: When choosing one of the options "Script 1" and "Script 2" for the first time, the .js-file is loaded and the script is executed. The according text appears in the <div>. When choosing again nothing happens. Expected Results: Every time choosing one of the options "Script 1" and "Script 2" the according .js-file should be loaded time and the code should be executed thus changing the text in the div accordingly.
Comment 1•19 years ago
|
||
Please attach a testcase showing the problem: https://bugzilla.mozilla.org/attachment.cgi?bugid=292792&action=enter
Extract the files and open the test.html. From the listbox choose either "Script 1" or "Script 2". On the first choice the accroding script is loaded and the contents of the div is changed, displaying a text. Any further choice of one of the scripts has no effect.
Summary: JS/Dom: setting scr-attribute for script tag is only possible once. Any further setting is ignored → JS/Dom: setting src-attribute for script tag is only possible once. Any further setting is ignored
Comment 3•19 years ago
|
||
Confirmed with SeaMonkey 2005070906-trunk/Win-2K. (Not so new problem because I experienced this bug's phenomenon on older Mozilla in last year.) This problem can easily be examined when html/scripts are placed at server. http://www.h2.dion.ne.jp/~radon/test/Script-SRC-Change/script-src-change-01.html (This test case is similar to attachment 182568 [details].) (1) Clear cache (2) Load HTML (SRC of <SCRIPT> is script1.js) (3) Click button and change SRC to script2.js (A) SRC attribute is changed to script2.js. Variable which will be set by "script2.js" is still "undefined". (B) See about:cache/"Disk cache device"/"List Cache Entries" => "script1.js" only. "script2.js" is not got from server. (C) "View Page Info"/Privacy/Scripts says "script2.js" is used. (B) indicates "loading" on SRC change isn't done, not "loaded but not executed". (C) indicates that this bug can be an easy script source name hiding method on Mozilla. This is not a problem if initial SRC value is written on HTML source(my test case). But if first SRC is put by JavaScript and the SRC is changed to other one by JavaScript(attachment 182568 [details] case), finding script really used becomes slightly difficult. So SRC attribute change of SCRIPT tag should be inhibited until proper SRC change handling will be implemented on SCRIPT tag.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 4•19 years ago
|
||
Changing to Product=Core/Component=DOM. If not appropriate, change to proper one, please.
Component: General → DOM
Product: Firefox → Core
Version: 1.0 Branch → Trunk
Comment 5•19 years ago
|
||
What is the meaning of SRC change of <SCRIPT>? - Whether the new script is to be executed or not. - Whether variables defined by old SRC is to be kept or is to be destroyed. - Whether functions defined by old SRC is to be kept or is to be destroyed. - Whether functions defined in both SRC is to be considered as duplicate definition or is to be replaced. - What should be done if new SRC document.write'ed "<script>....</script>"? What is spec in this case? What is user's expectation?
Comment 6•19 years ago
|
||
> What is user's expectation?
I would expect that loading two scripts this way would give the same result at
concatinating the content of the two files into one, and loading it. That is,
the rules for handling duplicates, redefinitions, etc. should be like that.
Updated•18 years ago
|
Assignee: nobody → general
QA Contact: general → ian
Comment 7•16 years ago
|
||
HTML 5 clearly defines behaviour upon SRC attribute change.
> http://www.w3.org/html/wg/html5/#script
> 4.3.1 The script element
>(snip)
> Changing the src, type, charset, async, and defer attributes dynamically
> has no direct effect; these attribute are only used at specific times
> described below (namely, when the element is inserted into the document).
>(snip)
Although HTML 5 is still draft, I think this bug can be closed as INVALID or WONTFIX.
Updated•15 years ago
|
Assignee: general → nobody
QA Contact: ian → general
Comment 8•6 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•