document.write 存在几个问题?应该注意
document.write (henceforth DW) does not work in XHTML
- XHTML 不支持
DW executed after the page has finished loading will overwrite the page, or write a new page, or not work
- 如果在页面加载完后执行,会覆盖整个页面 或者 输出一个新的页面 或 不能工作
DW executes where encountered: it cannot inject at a given node point
- 不能在指定节点注入
DW is effectively writing serialised text which is not the way the DOM works conceptually, and is an easy way to create bugs (.innerHTML has the same problem)
document.write VS appendChild
someScript.js
console.log('2');
index1.htm
<script>
console.log('1');
var script = document.createElement('script');
script.src = 'someScript.js';
document.write(script.outerHTML);
</script>
<script>
console.log('3');
</script>
index2.htm
<script>
console.log('1');
var script = document.createElement('script');
script.src = 'someScript.js';
document.body.appendChild(script);
</script>
<script>
console.log('3');
</script>
结果: index1.html 1、2、3 index2.html 1、3、2 ;
document.write 存在几个问题?应该注意的更多相关文章
- document.documentElement.clientHeight 与 document.body.clientHeight(杜绝千篇一律的抄袭!!)
document.documentElement.clientHeight 与 document.body.clientHeight用来获取页面可视高度我觉得有点问题.这两个应该不是一个东西. 页面中 ...
- jquery中的$(document).ready(function() {});
当文档载入时执行function函数里的代码, 这部分代码主要声明,页面加载后 "监听事件" 的方法.例如: $(document).ready( $("a") ...
- document.compatMode
在我电脑屏幕上显示的 电脑是 1920*1080这是在document.compatMode:css1Compat模式 window.screen.availWidth 1920 window.scr ...
- 谈谈document.ready和window.onload的区别
在Jquery里面,我们可以看到两种写法:$(function(){}) 和$(document).ready(function(){}) 这两个方法的效果都是一样的,都是在dom文档树加载完之后执行 ...
- Windows.document
一.找到元素: document.getElementById("id");根据id找,最多找一个 var a =document.getElementById("id& ...
- Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.
启动tomcat, 出现, ( 之前都是好好的... ) [lk ] ERROR [08-12 15:10:02] [main] org.springframework.web.context.Con ...
- JavaScript权威设计--JavaScript脚本化文档Document与CSS(简要学习笔记十五)
1.Document与Element和TEXT是Node的子类. Document:树形的根部节点 Element:HTML元素的节点 TEXT:文本节点 >>HtmlElement与 ...
- $(document).ready() 与window.onload的区别
1.执行时间 window.onload必须等到页面内包括图片的所有元素加载完毕后才能执行. $(document).ready()是DOM结构绘制完毕后就执行,不必等到加载完毕. 2.编写个数不同 ...
- Both must set "document.domain" to the same value to allow access.
有两个域名指向我的网站,其中一个域名访问我的网站的话就可以看到日期控件 另一个域名访问我的网站不能看到日期控件, 在EF中使用日期控件,浏览器审查元素后看到,报这个错误“Both must set & ...
- 关于xml加载提示: Error on line 1 of document : 前言中不允许有内容
我是在java中做的相关测试, 首先粘贴下报错: 读取xml配置文件:xmls\property.xml org.dom4j.DocumentException: Error on line 1 of ...
随机推荐
- AngularJS初步
AngularJS特点 遵循AMD规范 不需要操作节点 对于jquery,一般是利用现有完整的DOM,然后在这戏Dom的基础上进行二次调教了:而对于AngularJS等框架则是根据数据模型以及其对应用 ...
- K3整理
当金蝶提示“该模块使用已超过正式版许可最大数!”,需要解决的办法是: 打开K3的“帐套管理”系统,“系统(S)”菜单-“系统使用状况(D)”-系统使用状态窗口,然后点击橡皮擦 删除即可了.
- Memory Analyzer Blog
引用:http://memoryanalyzer.blogspot.jp/2008/05/automated-heap-dump-analysis-finding.html Dienstag, 27. ...
- 如何修改UIButton按下后默认的蓝色效果
其实有两个简单方法:1.修改xib属性检查器Highlight Tint的值: 2.通过代码修改:btn.tintColor=[UIColor grayColor];或者[btn setTintCol ...
- Objective-C 协议(接口)
Objective-C 协议类似于java语言中的接口 新建文件步骤:Objective-C File ---> File Type = "Protocol" @protoc ...
- windows下wchar_t* 转char*
这个在windows下很常见,常用,留个档. 一般用这个函数: size_t wcstombs( char *mbstr, const wchar_t *wcstr, size_t count ); ...
- gnuplot
一. 简介 gnuplot是一个命令行驱动的科学绘图工具,可将数学函数或数值资料以平面图或立体图的形式画在不同种类终端机或绘图输出装置上.gnuplot既支持命令行交互模式,也支持脚本. 二. 特性 ...
- hdu 1853 最小费用流好题 环的问题
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others) Tota ...
- 06_Elasticsearch 批量获取mget
06_Elasticsearch 批量获取mget 现在有: http://192.168.32.81:9200/bank/bank_account/1 http://192.168.32.81:92 ...
- ElasticSearch大批量数据入库
最近着手处理大批量数据的任务. 现状是这样的,一个数据采集程序承载大批量数据的存储和检索.后期可能需要对大批量数据进行统计. 数据分布情况 13个点定时生成采集结果到4个文件(小文件生成周期是5分钟) ...