document.getElementById("")赋值问题
<html>
<head>
<script>
function cc()
{
var cf=window.screen.width;
alert(cf)
if(cf<=1920)
{
cf=-(1920-cf)/2
}
else if(cf>1920)
{
cf=(cf-1920)/2
}
document.getElementById("m1").style.marginLeft=cf;
alert(cf)
}
</script>
</head>
<body onLoad="cc()">
<div style=" width:100%; overflow:hidden;" id="a">
<div style="width:1920px; height:500px;" id="m1"><img src="images/bar3.png" width="1920" height="500" text-align:center></div>
</div>
</body>
</html>
上面可以给M1进行左移赋值:document.getElementById("m1").style.marginLeft=cf;
但在第一行加这行后:<!doctype html>
M1就赋值失败,请问一般HTML文件都有<!doctype html>,如何处理?