innerHTML支持? [英] innerHTML support?

查看:52
本文介绍了innerHTML支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



嘿所有,


AFAIR,innerHTML最初是MS专有的,但是Mozilla也实现了它。

。有谁知道其他浏览器是否支持它?这不是W3C DOM的

,是吗?一个快速的GIS似乎对此回答不,但是你这两个人比我更善于找到这些东西。 ;)


这个页面似乎认为Opera 7,Safari和IE Mac很酷,它们也很酷,而且它看起来更快。它还暗示innerHTML不在W3C DOM的
中。这是对的吗?
http://www.quirksmode.org/ dom / innerhtml.html


任何人都有关于innerHTML的任何警告?什么时候应该使用?当

应该使用DOM方法吗?

最重要的是,浏览器是否同样实现它?


TIA


-

-

~kaeli~

不要嘲笑Happy Fun Ball!
http://www.ipwebdesign.net/wildAtHeart
< a rel =nofollowhref =http://www.ipwebdesign.net/kaelisSpacetarget =_ blank> http://www.ipwebdesign.net/kaelisSpace


Hey all,

AFAIR, innerHTML started as MS proprietary, but Mozilla implemented it
as well. Does anyone know if any other browsers support it? It is not in
the W3C DOM, is it? A quick GIS seemed to answer ''no'' to that, but you
guys are better at finding these things than I am. ;)

This page seems to think Opera 7, Safari, and IE Mac are cool with it
too, and it seems to be faster. It also implies that innerHTML is NOT in
the W3C DOM. Is this right?
http://www.quirksmode.org/dom/innerhtml.html

Anyone have any caveats about innerHTML? When should it be used? When
should DOM methods be used instead?
Most importantly, do the browsers implement it the same?

TIA

--
--
~kaeli~
Do not taunt Happy Fun Ball!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

推荐答案

kaeli< ti ****** @ NOSPAM.comcast.net>写道:
kaeli <ti******@NOSPAM.comcast.net> writes:
AFAIR,innerHTML起初是MS专有的,但Mozilla也实现了它。有谁知道其他浏览器是否支持它?


我知道Opera 7和Safari / Konqueror。

它不在W3C DOM中,是吗?


No.

这个页面似乎认为Opera 7,Safari和IE Mac也很酷,它似乎也是快点。


是的,IE(自IE 4以来的任何版本),Mozilla(任何基于Gecko的浏览器),

基于KHTML的浏览器(Konqueror和Safari)和Opera那也是我确定的那些




嗯。比...快? :)

它还暗示innerHTML不在W3C DOM中。这是对的吗?
http://www.quirksmode.org/ dom / innerhtml.html

绝对。

任何人都有关于innerHTML的任何警告?


这不是标准。它可能比直接创建节点慢,

但是在当前的Javascript中,脚本的解释开销

本身比解析HTML更糟糕。这可能会改变,可能不会这么大。


我真的不喜欢传递未解析的HTML,大致相同

我不喜欢使用eval的原因:它很容易出错。


你可以制作无效的HTML(甚至是语法错误的HTML)

并将其输入另一个验证页面,* no *金额

验证将告诉您。至少,当使用DOM方法时,

你只能制作正确的嵌套元素。


我推荐的方法是将可预测的文档片段添加到

页面比使用DOM方法更快,就是将它们放在页面中以隐藏元素内部开始

,并在
$ b时移动它们或克隆它们$ b你需要它。


另一方面,DOM方法在大多数情况下都能正常工作,除非你b $ b动态构建庞大的文档(然后是innerHTML)如果使用不当,也可能会很慢。

什么时候应该使用?


当你知道目标受众只会使用支持

的浏览器时(包括未来的浏览器)

什么时候应该DOM改为使用哪些方法?


我会一直说,但我知道纯粹主义者:)


另一方面,我永远不会直接用DOM

方法做大量的工作。它们太冗长了。我通常有实用工具

函数,可以更容易地构建更大的结构

最重要的是,浏览器是否实现了相同的功能?
AFAIR, innerHTML started as MS proprietary, but Mozilla implemented it
as well. Does anyone know if any other browsers support it?
Opera 7 and Safari/Konqueror that I know of.
It is not in the W3C DOM, is it?
No.
This page seems to think Opera 7, Safari, and IE Mac are cool with it
too, and it seems to be faster.
Yes, IE (any version since IE 4), Mozilla (any Gecko based browser),
KHTML-based browsers (Konqueror and Safari) and Opera 7. That''s the
ones I am certain of too.

Hmm. Faster than? :)
It also implies that innerHTML is NOT in the W3C DOM. Is this right?
http://www.quirksmode.org/dom/innerhtml.html
Absolutely.
Anyone have any caveats about innerHTML?
It''s not standard. It could be slower than creating the nodes directly,
but in current Javascript, the interpretive overhead of the script
itself is worse than the parsing of HTML. That can change, probably
not significantly so.

My real dislike is for passing around unparsed HTML, for much the same
reason that I dislike using "eval": It''s error prone.

You can make invalid HTML (or even plain syntactically wrong "HTML")
and enter it into an otherwise validating page, and *no* amount of
validation will tell you that. At least, when using DOM methods,
you can only make properly nested elements.

The method I recommend for adding predictable document fragments to a
page faster than with DOM methods, is to put them in the page to begin
with, inside a hidden element, and either move them or clone them when
you need it.

On the other hand, DOM methods work fine in most cases, unless you
are building humongous documents dynamically (and then innerHTML can
be slow too if used improperly).
When should it be used?
When you know the target audience will only use browsers that supports
it (including future browsers :)
When should DOM methods be used instead?
I''d say all the time, but I''m a known purist :)

On the other hand, I would never do large amounts of work with the DOM
methods directly. They are simply too verbose. I usually have utility
functions that makes it easier to build larger structures
Most importantly, do the browsers implement it the same?




差不多。


错误纠正当然不同,但对于有效的,标签完整的

HTML,结果大致相同。可能还有一些例外,但我唯一记得的是:

在IE中,对于大多数与表相关的元素,innerHTML属性是

只读(不是TD和TH,但其余几乎都是)。


祝你好运:)

/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡色彩:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断力的信仰只会降低精神神圣。''



Almost.

Error correction is ofcourse different, but for valid, tag-complete
HTML, the results are mostly the same. There are probably a few
more exceptions, but the only one I can remember is:
In IE, on most table-related elements the innerHTML property is
read-only (not TD and TH, but pretty much the rest).

Good luck :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


在文章< y8 ********** @ hotpop.com> ;, lr * @ hotpop.com 启发了我们

with ...
In article <y8**********@hotpop.com>, lr*@hotpop.com enlightened us
with...
这个页面好像是认为Opera 7,Safari和IE Mac它也很酷,它似乎也更快。
是的,IE(IE 4以后的任何版本),Mozilla(任何基于Gecko的浏览器),基于KHTML的浏览器(Konquero) r和Safari)和Opera 7.那也是我确定的那些。

嗯。比...快? :)
This page seems to think Opera 7, Safari, and IE Mac are cool with it
too, and it seems to be faster.
Yes, IE (any version since IE 4), Mozilla (any Gecko based browser),
KHTML-based browsers (Konqueror and Safari) and Opera 7. That''s the
ones I am certain of too.

Hmm. Faster than? :)
它还暗示innerHTML不在W3C DOM中。这是对的吗?
http://www.quirksmode.org/ dom / innerhtml.html
It also implies that innerHTML is NOT in the W3C DOM. Is this right?
http://www.quirksmode.org/dom/innerhtml.html




如果查看页面,它会比较innerHTML与
$ b的渲染时间$ b Dom方法。 innerHTML几乎赢得了所有这些。

我真的不喜欢传递未解析的HTML,这与我不喜欢使用eval的原因相同:它是'容易出错。


我真的没想到这一点。这是一个很好的观点。

我自己也没有使用它,但我看到这里发布的解决方案以及其他使用它的b $ b论坛,我总是在想那些

解决方案有多好。



If you look at the page, it compared rendering times of innerHTML vs.
Dom methods. The innerHTML won for pretty much all of them.

My real dislike is for passing around unparsed HTML, for much the same
reason that I dislike using "eval": It''s error prone.
I really didn''t think of that. That''s a great point.
I don''t use it myself, but I see solutions posted here and in other
forums that use it and I am always wondering just how good those
solutions are.

什么时候应该使用?
当你知道目标受众只会使用支持
它(包括未来的浏览器:)
When should it be used?
When you know the target audience will only use browsers that supports
it (including future browsers :)




嗯,那就是照顾它,不是吗? ;)



Well, that about takes care of that, doesn''t it? ;)

什么时候应该使用DOM方法?
When should DOM methods be used instead?



我会一直说,但我是一个纯粹的人:)



I''d say all the time, but I''m a known purist :)




是的,我也是,这就是我想知道的原因。有时候,由于缺少一个更好的术语,我已经太多了b / b
代码势利。我真的很擅长

有时过于复杂的事情。 *嘿*


-

-

~kaeli~

当时钟是饥饿,它可以追溯到四秒钟。
http://www.ipwebdesign.net/ wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



Yeah, me too, that''s why I was wondering. Sometimes, I''m TOO much of a
code-snob, for want of a better term. I''m really good at
overcomplicating things sometimes. *heh*

--
--
~kaeli~
When a clock is hungry, it goes back four seconds.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


2004年7月19日星期一22:16:53 +0200,Lasse Reichstein Nielsen

< lr * @ hotpop.com>写道:
On Mon, 19 Jul 2004 22:16:53 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
你可以制作无效的HTML(甚至是语法错误的HTML)
并将其输入另一个验证页面,并且* no * amount of <验证将告诉你。至少,当使用DOM方法时,你只能制作正确的嵌套元素。
You can make invalid HTML (or even plain syntactically wrong "HTML")
and enter it into an otherwise validating page, and *no* amount of
validation will tell you that. At least, when using DOM methods,
you can only make properly nested elements.




不,你不能,你可以很容易地制作一个无效的DOM - 例如我们

经常让人们抱怨在IE中制作一个

表时需要TBODY - 这不是因为它在将TR附加到一个TR时会出错

TABLE(在HTML中无效),但因为它没有显示。

innerHTML是不可能的 - 因为innerHTML会使用

暗示dtd的规则包含它。


Jim。

-

comp.lang.javascript常见问题 - http://jibbering.com/faq/



No you can''t, you can easily make an invalid DOM - for example we
often got people complaining about the TBODY required when making a
table in IE - that''s not because it errored when it appended a TR to a
TABLE (which isn''t valid in HTML) but because it just didn''t display.
That isn''t possible with innerHTML - since innerHTML will use the
implied rules from the dtd to include it.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/


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

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