可可WebView中innerhtml和outerhtml之间的区别 [英] Difference between innerhtml and outerhtml in cocoa WebView

查看:61
本文介绍了可可WebView中innerhtml和outerhtml之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用可可Web视图在应用程序中进行富文本编辑.只是与webkit中可用的innerHtml和externalHtml方法相混淆.

I am using cocoa webview for rich text editing in my application. Just confused with innerHtml and outerHtml method avaiable in webkit.

谁能解释一下两者之间有什么区别

Can anyone explain what is the difference between

[(DOMHTMLElement *)[[[webView mainFrame] DOMDocument] documentElement] outerHTML];

AND

[(DOMHTMLElement *)[[[webView mainFrame] DOMDocument] documentElement] outerText];

推荐答案

innerHTML 是表示HTML的DOM元素的属性在元素内部,即在开始和结束标签之间.它有被广泛复制,但是实现方式有所不同(可能是因为它尚未发布标准[1]),特别是在元素处理方式上属性.

innerHTML is a property of a DOM element that represents the HTML inside the element, i.e. between the opening and closing tags. It has been widely copied, however implementations vary (probably because it has no published standard[1]) particularly in how they treat element attributes.

outerHTML 与innerHTML相似,它是一个元素属性,包括开始,结束标记以及内容.它还没有像innerHTML那样被广泛复制,因此它或多或少仍然仅限IE.

outerHTML is similar to innerHTML, it is an element property that includes the opening an closing tags as well as the content. It hasn't been as widely copied as innerHTML so it remains more-or-less IE only.

<p id="pid">welcome</p>

innerHTML of element "pid" == welcome
outerHTML of element "pid" == <p id="pid">welcome</p>

和whereAs

innerText 容器的文本内容.

outerText 与innerText相同,在读取时可访问;在分配新值时替换整个元素.

outerText Same as innerText when accessed for read; replaces the whole element when assigned a new value.

<p id="pid">welcome</p>

innerText of element "pid" == welcome
outerText of element "pid" == welcome

这篇关于可可WebView中innerhtml和outerhtml之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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