<!doctype html>时JavaScript不起作用以正确的格式插入 [英] Javascripts not working when <!doctype html> inserted in correct format
本文介绍了<!doctype html>时JavaScript不起作用以正确的格式插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了一个网页,并且在页面上使用了一些javascript来移动一些html元素,但是当<!doctype html>
或任何类型的<!doctype>
s添加到页面的顶部!这个错误是什么?
我在google上搜索,发现<!doctype html>
是正确的格式,甚至stackoverflow源代码它但是当我用它JavaScript的不工作,但当它删除脚本工作正常& html对象正在移动,但由于删除<!doctype html>
Im developing a web page and im using some javascripts on the pages to move some html elements, but i found that javascript code is not working when <!doctype html>
or any type of <!doctype>
s added to the top of the page ! what is this error?
I search on google and i found <!doctype html>
is the correct format even stackoverflow source code has it but when i used it javascripts not working but when it removed script working fine & html object is moving but my styles are gone away because of removing <!doctype html>
outset; width:160px; background -color:lightyellow; font-weight:bold;> Moving Div< / div>
< / div>
< / div>
< / body>
< / html>
推荐答案
如果没有文档类型,浏览器会假定未标记的长度为以像素为单位使用文档类型,它们需要一个明确的单元。
Without a doctype, the browser assumes that unlabelled lengths are in pixels. With a doctype, they require an explicit unit.
obj.style.left = "100px";
obj.style.top = "10px";
这篇关于<!doctype html>时JavaScript不起作用以正确的格式插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文