Closed Bug 155146 Opened 23 years ago Closed 4 years ago

Build 2002053012. Embedded script tags fail in innerHTML

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows 98
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: brodgers, Unassigned)

Details

Attachments

(1 file)

Code with embedded script tag using defer attribute doesn't run. var txt = 'Test Pop Div<s'; txt += 'cript language=\"JavaScript\" defer>'; txt += 'alert(\"here\");</'; txt += 'script>'; o_mnuDiv = tmn.document.getElementById("mydiv") o_mnuDiv.innerHTML = txt; To recreate: 1.Make a page with a div 2.Add in JS code that sets innerHTML with embedded script 3.Embedded script fails to run Note: NS 6.2 supports this OK.
Dupe of 28293 ?
Ian, Could you use the word 'bug' before the bug numbers when pointing to other bugs? (eg, 'bug 28293', in this case). Bugzilla automatically produces a link to the bug when you do that, so it's a lot easier to check the bug you're talking about.
Ooops I usually do, must be that Monday morning thing!
Browser, not engine ---> DOM Level 0. The object |tmn| seems extraneous in the sample given above. I will attach the following testcase below: <body> <div id="mydiv"> <script> var txt = 'Test Pop Div<s'; txt += 'cript language=\"JavaScript\" defer>'; txt += 'alert(\"here\");</'; txt += 'script>'; o_mnuDiv = document.getElementById("mydiv") o_mnuDiv.innerHTML = txt; </script> </body>
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Attached file Reporter's testcase
Confirming bug. When I load the above testcase, I see this: IE6 Mozilla 20020617xx WinNT The text 'Test Pop Div' The text 'Test Pop DivTest Pop Div' An alert 'here' No alert I don't know why 'Test Pop Div' is rendered twice in Mozilla; perhaps that is a clue as to what's going wrong with the alert. No errors in the JavaScript Console -
Status: UNCONFIRMED → NEW
Ever confirmed: true
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Firefox 1.5.0.4 has the same bug. Still not fixed.
I just hit this scenario and played a little bit with it. Here is some information on innerHTML from Microsoft: http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerHTML.asp Some things to note (while testing their sample in IE6) 1. You must include DEFER attribute for that script to execute. 2. It can't be a single script tag, there needs to be something else there as well? This scenario is also quite peculiar is that Microsoft added a line to help people in getting their scripts to run when using innerHTML.
The fact that the defer attributes affects anything is bizarre since that attribute has an entierly different meaning. The reason we have disabled running <script>s when setting .innerHTML is that a lot of pages did things like foo.innerHTML = bar.innerHTML; or bar.innerHTML.replace(/text/, "TEXT"); where bar has a child that is a script element. This would break a lot of sites since they did not expect such commands to rerun the script.
I don't know all the cases, and some people could abuse things... but then again they can dynamically add scripts to the page... which would be the same.. My biggest concern for this issue is that this works in IE6 (albeit in a limited fashion) and I saw it used on a live site trying to get the JavaScript to work. The solution was to use a DEFER flag as documented by Microsoft, however none of the scenarios or examples that work in IE don't work in Firefox. P.S. This is not Windows 98 specific, I saw this on windows 2000 and I am sure it's the same on other platforms.
> The fact that the defer attributes affects anything is bizarre IE does _really_ weird things with the defer attribute. > some people could abuse things s/could/do, because the things work interoperably in browsers/. That is, generally script in innerHTML does not execute. Clearly IE does _something_ really weird with <script defer>, however. We might be able to duplicate it if someone specs our clearly _exactly_ what it does.
Assignee: general → nobody
QA Contact: desale → general
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

The behavior described by Jonas above has since been standardized.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: