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 ...
随机推荐
- HTML与CSS入门——第八章 使用外部和内部链接
知识点: 1.链接锚的使用方法 2.在自己的网站上的页面之间链接的方法 3.链接到外部内容的方法 4.链接到一个E-mail地址的方法 5.在新浏览器窗口中查看链接的方法 6.用CSS为链接添加样式的 ...
- WebApi2官网学习记录--HttpClient Message Handlers
在客户端,HttpClient使用message handle处理request.默认的handler是HttpClientHandler,用来发送请求和获取response从服务端.可以在clien ...
- Application 可以存储全局变量
Application.Lock(); Application["Name"]="小亮" Application.UnLock(); Response.Writ ...
- IntelliJ IDEA启动web项目时突然变慢的原因
在使用IntelliJ IDEA开发web项目过程中,有两次项目启动非常慢,大约要200s的时间: 第一次忘记是怎么解决的,第二次出现后,我就直接重新下载了代码,然后部署,启动,时间有恢复正常,只用了 ...
- linux下查找文件和文件内容
find /xxx -name "*" | xargs grep "某内容" /xxx表示路径,"*"表示在含有某关键字名字下的文件中查找, ...
- python 杂记
class TestA(object): def __init__(self): print("A is initing"); def foo(self): print(" ...
- JS小数位保留两位小数--toFixed()
parseInt,parseFloat,parseDouble在JS中是将值转换成相应的类型: 你必须要这样,才能实现: <script> alert(parseFloat ...
- Android再学习-20140928-布局
关于布局中的单位 PX是像素,这个没有问题.另外还有两个单位,一个是dp,这个是个相对单位,在任何分辨率的屏幕上显示效果是一样的,所以用dp来进行控件的大小设置.另外,字体的设置推荐用sp,这样字体可 ...
- centos mysql 数据存储目录安装位置
rpm -ql mysql查看安装位置 MYSQL默认的数据文件存储目录为/var/lib/mysql.假如要把目录移到/home/data下需要进行下面几步: 1.home目录下建立data目录 c ...
- Hibernate整合Struts2时报错
今天在整合Hibernate和Struts2的时候遇到一个问题 总是出现各种异常,经过仔细检查,代码本身并没有问题, ----------------------------------------- ...