document.getElementById为什么找不到对象
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style type="text/css">
#toolTip{width:205px;}
#toolTip{display:none;}
#toolTip{position:absolute;color:#333;}
#tip_top{background:url(images/tip_top.gif) no-repeat top center;height:20px;}
#tip_middle{background:url(images/tip_middle.gif) repeat-y center;padding:0 10px;}
#tip_bottom{background:url(images/tip_bottom.gif) no-repeat top center;height:20px;}
</style>
<script type="text/javascript" language="javascript">
toolTip = document.createElement("DIV");
toolTip.id = "toolTip";
tip_top = document.createElement("DIV");
tip_top.id = "tip_top";
tip_middle = document.createElement("DIV");
tip_middle.id = "tip_middle";
tip_bottom = document.createElement("DIV");
tip_bottom.id = "tip_bottom";
toolTip.appendChild(tip_top);
toolTip.appendChild(tip_middle);
toolTip.appendChild(tip_bottom);
title_content = "";
cStyle = toolTip.style;
cStyle.position = "absolute";
//for(i = 0; i < document.all.length; i++){
//alert(document.all(i).tagName);
//}
var _tempdoc= document.getElementById("container");
//alert(_tempdoc);
_tempdoc.appendChild(toolTip);
function showTooltips(evt)
{
evt = window.event?window.event:evt;
srcElem = evt.srcElement?evt.srcElement:evt.target;
if(srcElem.tagName.toUpperCase()=="A" && srcElem.title!=""){
window.title_content = srcElem.title;
srcElem.title = "";
tip_middle.innerHTML = window.title_content;
pos = findPosition(srcElem);
x=pos[0];y=pos[1];
cStyle.left = x+"px";
cStyle.top = y+25+"px";
cStyle.display = "block";
}
}
function findPosition( oLink ) {
if( oLink.offsetParent ) {
for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
posX += oLink.offsetLeft;
posY += oLink.offsetTop;
}
return [ posX, posY ];
} else {
return [ oLink.x, oLink.y ];
}
}
function hideTooltips(evt)
{
evt = window.event?window.event:evt;
srcElem = evt.srcElement?evt.srcElement:evt.target;
srcElem.title= window.title_content;
window.title_content = "";
cStyle.display = "none";
}
document.onmouseover = showTooltips;
document.onmouseout = hideTooltips;
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #container --></div>
</form>
</body>
</html>