Home > Web Front-end > JS Tutorial > body text

设置iframe的document.designMode后仅Firefox中其body.innerHTML为br_javascript技巧

WBOY
Release: 2016-05-16 17:55:51
Original
1573 people have browsed it

重现如下:

复制代码 代码如下:




设置iframe的document.designMode后仅Firefox中其body.innerHTML为br




<script> <BR>var ifr = document.getElementsByTagName('iframe')[0]; <BR>var doc = ifr.contentWindow.document; <BR>function prif() { <BR>console.log(ifr.contentWindow.document.body.innerHTML); <BR>} <BR>function changeDesignMode() { <BR>ifr.contentWindow.document.designMode = 'On'; <BR>} <BR>prif(); <BR></script>



以上代码iframe的body中没有写入任何html标记。正常情况下输出ifr.contentWindow.document.body.innerHTML应该是空字符串。但Firefox中有点特殊。
请按下面步骤依次操作。
Firefox中打开该html默认输出了空字符串
设置iframe的document.designMode后仅Firefox中其body.innerHTML为br_javascript技巧
控制台中执行changeDesignMode方法,再执行prif方法,这时输出的innerHTML为“
”,如下
设置iframe的document.designMode后仅Firefox中其body.innerHTML为br_javascript技巧
Chrome/Safari/Opera输出的仍然是空字符串。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!