奇怪的innerHTML / appendChild IE崩溃了 [英] Weird innerHTML/appendChild IE crash

查看:60
本文介绍了奇怪的innerHTML / appendChild IE崩溃了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道之前的html和之后的html任何人都可以理解为什么以下代码崩溃IE但是如果我添加< br />在任何情况下

< input>标签它不是吗?


******************************* ******************* ****

HTML =" html before" ;;

HTML + = " \

< label for =''m-bx''> X:< / label>< input type =''text''id =''m-bx ''/> \

< label for =''m-by''> Y:< / label>< input type =''text''id ='' m-by''/> \

< label for =''m-bw''>宽度:< / label>< input type =''text''id =''m-bw''/> \

< label for =''m-bh''>高度:< / label>< input type =''text ''id =''m-bh''/>"

HTML + =" html after" ;;


bEditor = document.createElement (DIV);

bEditor.innerHTML = HTML;

dW.appendChild(bEditor);

****** ******************************************** ****

Without knowing "html before" and "html after" can anyone fathom any
reason why the following code crashes IE but if I add <br/> after ANY
<input> tags it doesn''t?

************************************************** ****
HTML = "html before";
HTML += "\
<label for=''m-bx''>X:</label><input type=''text'' id=''m-bx''/>\
<label for=''m-by''>Y:</label><input type=''text'' id=''m-by''/>\
<label for=''m-bw''>Width:</label><input type=''text'' id=''m-bw''/>\
<label for=''m-bh''>Height:</label><input type=''text'' id=''m-bh''/>"
HTML += "html after";

bEditor = document.createElement("DIV");
bEditor.innerHTML = HTML;
dW.appendChild(bEditor);
************************************************** ****

推荐答案

ni ****** @ hotmail.com 写道:
不知道之前的html和之后的html任何人都可以理解以下代码崩溃IE的原因,但如果我添加< br />在任何
< input>之后标签它不是吗?
Without knowing "html before" and "html after" can anyone fathom any
reason why the following code crashes IE but if I add <br/> after ANY
<input> tags it doesn''t?




使用document.body for dW不会在我的系统上崩溃IE。 dW

指向哪里?

JW



Doesn''t crash IE on my system using document.body for dW. Where does dW
point to?
JW




Janwillem Borleffs写道:

Janwillem Borleffs wrote:
ni******@hotmail.com 写道:
不知道之前的html和之后的html任何人都可以理解以下代码崩溃IE的原因,但如果我添加< br />在任何
< input>之后标签它不是吗?
Without knowing "html before" and "html after" can anyone fathom any
reason why the following code crashes IE but if I add <br/> after ANY
<input> tags it doesn''t?



使用document.body for dW不会在我的系统上崩溃IE。 dW
指向哪里?



Doesn''t crash IE on my system using document.body for dW. Where does dW
point to?




dW只是另一个DIV,而html before和之后的html每个

代表100多行html代码。当然我可能会逐行消除代码并找出罪魁祸首,但我不会这样做,因为它现在无论如何都可以解决问题我太奇怪了,我完全不知道该找什么。我的意思是,你可以想象任何情况:


"< label for =''m-bh''> Height:< / label>< input type =''text''id =''m-bh''/>< br />"

的作品

并且

"< label for =''m-bh''>高度:< / label>< input type =''text''id =''m-bh' '/>"

不是吗?


我的意思是,WTF ??



dW is just another DIV, and "html before" and "html after" each
represents 100+ lines of html code. Of course I can potentially
eliminate the code line by line and find out the culprit but I''m not
going to do that because it works now anyway and the problem is too
weird that I have absolutely no idea what to look for. I mean, can you
imagine ANY situation where:

"<label for=''m-bh''>Height:</label><input type=''text'' id=''m-bh''/><br/>"
works
and
"<label for=''m-bh''>Height:</label><input type=''text'' id=''m-bh''/>"
doesn''t?

I mean, WTF??

< br>

2005年11月5日05:57:23 -0800, ni ****** @ hotmail.com 写道:
On 5 Nov 2005 05:57:23 -0800, ni******@hotmail.com wrote:
我的意思是,你能想象任何情况:

< label for =''m- bh''>高度:< / label>< input type =''text''id =''m-bh''/>< br />"
作品和
"< label for =''m-bh''>高度:< / label>< input type =''text''id =''m-bh''/> ;
不是吗?
I mean, can you
imagine ANY situation where:

"<label for=''m-bh''>Height:</label><input type=''text'' id=''m-bh''/><br/>"
works
and
"<label for=''m-bh''>Height:</label><input type=''text'' id=''m-bh''/>"
doesn''t?




两者都不是有效的HTML,都会触发IE中的错误纠正模式,如果

你要避免错误,首先要有效的

fragements。 IE不会在非HTML用户代理中使用XHTML。它很可能仅仅是因为BR没有触发IE正在进行的任何错误恢复

能够解析废话你正在解除它。


吉姆。



Neither are valid HTML, both trigger error correcting modes in IE, if
you''re going to avoid a bug, the first thing is to have valid
fragements. IE don''t use XHTML in a non-HTML user agent. It''s likely
simply that the BR doesn''t trigger whatever error recovery IE is doing
to be able to parse the crap you''re freeding it.

Jim.


这篇关于奇怪的innerHTML / appendChild IE崩溃了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆