Discussion:
1 line of jQuery crashes IE8rc1@win2003
(too old to reply)
yoursunny.com
2009-02-20 03:05:01 UTC
Permalink
I'm running IE8rc1 (en-us) on Windows Server 2003 (zh-cn).

I'm using jQuery to insert a stylesheet into the HTML page, but iexplore.exe
Tab-process crashes every time.


The code I'm using is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>1 line of jQuery crashes ***@win2003</title>
</head><body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script type="text/javascript">
//discovered by yoursunny.com
$(document).ready(function(){
$('<link rel="stylesheet"
type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');
});
</script>
</body></html>


An equivalent without jQuery is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>5 lines of DOM2 JavaScript crash ***@win2003</title>
</head><body>
<script type="text/javascript">
//discovered by yoursunny.com
//this is actually the 'core' of jQuery-IEcrash.htm
var div=document.createElement('div');
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';
div=div.lastChild;
var link=div.childNodes[0];
link.setAttribute('href','http://css.cn.msn.com/c/green14.css');
</script>
</body></html>


This behavior is constantly reproducible.
This behavior exists when IE8rc1 is running in No-Addons mode.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?mid=1d8bf8b8-8b37-4490-91a1-a4e04fd85c92&dg=microsoft.public.internetexplorer.beta
rob^_^
2009-02-20 05:34:31 UTC
Permalink
Hi sunny,

Here are 2 errors from validator.w3.org for the second test page.

Line 12, Column 22: document type does not allow element "div" here.
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';✉
The element named above was found in a context where it is not allowed. This
could mean that you have incorrectly nested elements -- such as a "style"
element in the "body" section instead of inside "head" -- or two elements
that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).


Line 12, Column 62: document type does not allow element "link" here.
…erHTML='div<div><link rel="stylesheet" type="text/css"/></div>';✉
The element named above was found in a context where it is not allowed. This
could mean that you have incorrectly nested elements -- such as a "style"
element in the "body" section instead of inside "head" -- or two elements
that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).

See the thread below "RE: IE8 RC1 crash" by TSW for an explanation. I think
though IE8 should not freak out totally and crash. That is the issue despite
your invalid markup.

Regards.
Post by yoursunny.com
I'm running IE8rc1 (en-us) on Windows Server 2003 (zh-cn).
I'm using jQuery to insert a stylesheet into the HTML page, but iexplore.exe
Tab-process crashes every time.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script type="text/javascript">
//discovered by yoursunny.com
$(document).ready(function(){
$('<link rel="stylesheet"
type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');
});
</script>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript">
//discovered by yoursunny.com
//this is actually the 'core' of jQuery-IEcrash.htm
var div=document.createElement('div');
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';
div=div.lastChild;
var link=div.childNodes[0];
link.setAttribute('href','http://css.cn.msn.com/c/green14.css');
</script>
</body></html>
This behavior is constantly reproducible.
This behavior exists when IE8rc1 is running in No-Addons mode.
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?mid=1d8bf8b8-8b37-4490-91a1-a4e04fd85c92&dg=microsoft.public.internetexplorer.beta
yoursunny.com
2009-02-20 07:42:01 UTC
Permalink
Hi rob

Thanks for your quick response.

I modified my code, and it validates against XHTML 1.0 Strict on
validator.w3.org. However, it still crashes IE8rc1 (now I am runing IE8rc1
en-us in Windows Vista Enterprise en-us).


jQuery version:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>1 line of jQuery crashes ***@vista</title>
</head><body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script type="text/javascript">//<![CDATA[
//discovered by yoursunny.com
$(document).ready(function(){
$('<link rel="stylesheet"
type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');
});
//]]></script>
</body></html>


non-jQuery version:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>5 lines of DOM2 JavaScript crash ***@vista</title>
</head><body>
<script type="text/javascript">//<![CDATA[
//discovered by yoursunny.com
//this is actually the 'core' of jQuery-IEcrash.htm
var div=document.createElement('div');
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';
div=div.lastChild;
var link=div.childNodes[0];
link.setAttribute('href','http://css.cn.msn.com/c/green14.css');
//]]></script>
</body></html>


My code is different to TSW's post. TSW's code is manipulating some DOM
nodes that is not completely loaded, while mine is creating some nodes
without injecting them into the DOM tree. When setting the href attribute in
a LINK node created by innerHTML, IE crashes.
Post by rob^_^
Hi sunny,
Here are 2 errors from validator.w3.org for the second test page.
See the thread below "RE: IE8 RC1 crash" by TSW for an explanation. I think
though IE8 should not freak out totally and crash. That is the issue despite
your invalid markup.
Regards.
rob^_^
2009-02-20 09:14:54 UTC
Permalink
Hi Sunny,

Yes, but you are trying to inject a link element within the body block. This
is not allowed.


Here is your Non JQuery example with the javascript block replaced by its
content so the W3C validator can correctly parse the outputted markup. This
makes the error immediate to the eye.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>5 lines of DOM2 JavaScript crash ***@vista</title>
</head><body>
<div>
<link rel="stylesheet" type="text/css"
href="http://css.cn.msn.com/c/green14.css"/>
</div>
</body></html>

Line 9, Column 82: document type does not allow element "link" here. <<<<<
This is the actual error >>>>>>>
…http://css.cn.msn.com/c/green14.css"/>✉
The element named above was found in a context where it is not allowed. This
could mean that you have incorrectly nested elements -- such as a "style"
element in the "body" section instead of inside "head" -- or two elements
that overlap (which is not allowed).

<<<< this is just commentary - indicating the possible cause of the error
and its implications for correctly parsing the rest of the markup
One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).

<<<< Workaround/ Correct method for adding or disabling external stylesheets
by script >>>>>
Use the stylesheets collection to append a new one or toggle the disable
attribute of an existing stylesheet <link> tag.

(Actually you will find that the W3C validators will give a warning about
the disable attribute in <link> tags... ROC)

You are right it has nothing to do with appending elements before the DOM is
parsed.

You are right, IE should not crash. Have you tried this in another browser?
Check that "Automatically recover from rendering errors with Compatibility
View" on the Internet Options>Advanced tab. (not sure if this setting will
stop the crashing) and that you have "Display notification about every
script error..." checked.

This is what happens when we allow users to enter unvalidated or illegal
markup or script blocks into html edit controls. viz... Facebook

I will raise a ticket with connect...

Title - "Browser chokes when fed junk" (joking)

... but along those lines. I will post back with a ticket number for you to
track. (I may actually use that Title, to make everyone laugh. I should post
it to a blog on Facebook as a test case.)

Regards.
Post by yoursunny.com
Hi rob
Thanks for your quick response.
I modified my code, and it validates against XHTML 1.0 Strict on
validator.w3.org. However, it still crashes IE8rc1 (now I am runing IE8rc1
en-us in Windows Vista Enterprise en-us).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script type="text/javascript">//<![CDATA[
//discovered by yoursunny.com
$(document).ready(function(){
$('<link rel="stylesheet"
type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');
});
//]]></script>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript">//<![CDATA[
//discovered by yoursunny.com
//this is actually the 'core' of jQuery-IEcrash.htm
var div=document.createElement('div');
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';
div=div.lastChild;
var link=div.childNodes[0];
link.setAttribute('href','http://css.cn.msn.com/c/green14.css');
//]]></script>
</body></html>
My code is different to TSW's post. TSW's code is manipulating some DOM
nodes that is not completely loaded, while mine is creating some nodes
without injecting them into the DOM tree. When setting the href attribute in
a LINK node created by innerHTML, IE crashes.
Post by rob^_^
Hi sunny,
Here are 2 errors from validator.w3.org for the second test page.
See the thread below "RE: IE8 RC1 crash" by TSW for an explanation. I think
though IE8 should not freak out totally and crash. That is the issue despite
your invalid markup.
Regards.
rob^_^
2009-02-21 23:00:55 UTC
Permalink
Posted to connect.

https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=416918

Please view and vote.
Post by yoursunny.com
I'm running IE8rc1 (en-us) on Windows Server 2003 (zh-cn).
I'm using jQuery to insert a stylesheet into the HTML page, but iexplore.exe
Tab-process crashes every time.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script type="text/javascript">
//discovered by yoursunny.com
$(document).ready(function(){
$('<link rel="stylesheet"
type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');
});
</script>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>
<script type="text/javascript">
//discovered by yoursunny.com
//this is actually the 'core' of jQuery-IEcrash.htm
var div=document.createElement('div');
div.innerHTML='div<div><link rel="stylesheet" type="text/css"/></div>';
div=div.lastChild;
var link=div.childNodes[0];
link.setAttribute('href','http://css.cn.msn.com/c/green14.css');
</script>
</body></html>
This behavior is constantly reproducible.
This behavior exists when IE8rc1 is running in No-Addons mode.
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?mid=1d8bf8b8-8b37-4490-91a1-a4e04fd85c92&dg=microsoft.public.internetexplorer.beta
Stephan Kristyn
2010-01-13 04:47:01 UTC
Permalink
Post by rob^_^
Posted to connect.
https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=416918
Please view and vote.
Yoursunny, can you verify with a RTM Version of IE8 that the issue has been
fixed ?

regards,
stephan
--
www.meshfields.de/blog
rob^_^
2010-01-13 08:11:31 UTC
Permalink
Hi Stephan,

Which version of IE8. It was branched at Win7 and XP.

Ok... I have received confirmation from connect that has been 'fixed' for
Win7 IE8.

The connect issue ticket has the status of the issue as reported by the
connect support team and IE Testers.

You can post your own comments on that issue ticket at connect. Notification
will be broadcast to those connect users following the issue.

I am too busy fighting fires with web developers who cannot code to
standards and who do not bother to validate their markup. Apples ain't
Pears.

Although not confirmed I would suspect that Win7/IE8 still has a degree of
junk intolerance. You can follow my posts at the IE Web Development Forum.

Regards.
Post by Stephan Kristyn
Post by rob^_^
Posted to connect.
https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=416918
Please view and vote.
Yoursunny, can you verify with a RTM Version of IE8 that the issue has been
fixed ?
regards,
stephan
--
www.meshfields.de/blog
Loading...