当前位置: 代码迷 >> JavaScript >> window.onload 里面的javascript程序返回的innerhtml如何控制位置
  详细解决方案

window.onload 里面的javascript程序返回的innerhtml如何控制位置

热度:295   发布时间:2012-04-19 14:36:43.0
window.onload 里面的javascript程序返回的innerhtml怎么控制位置?
现在编一个网页 用了一个script返回一个innerHtml, 但是每次返回的东西都会挡住原来我设计的图片什么的。 不知道是什么原因, 请大神们赐教啊~ 我在那个返回的html也试着加过div标签 但是还是没有作用 可能是我不懂怎么加吧
HTML code
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<link rel="stylesheet" href="2col_leftNav.css" type="text/css" />
<style type="text/css">
<!--
.STYLE2 {font-size: x-large}
.STYLE3 {font-size: large}
-->
</style>
</head>
<!-- The structure of this file is exactly the same as 2col_rightNav.html;
     the only difference between the two is the stylesheet they use -->
<body>
<div id="masthead">
  <h1 id="siteName">F-Droid</h1>
</div>
<!-- end masthead -->
<div id="content">
  <h2 id="pageName">HomePage</h2>
  <div class="feature"> <img src="cropped-fdroidheader.jpg" alt="" width="720" height="180" />
  <br>
    <h3>F-Droid</h3>
    <p>An adroid app store which can support both IPv4 and IPv6 </p>
  </div>
  <div class="story">
  <br><br><br><br><br><br>
  <SCRIPT>

function start(){
var xmlDoc = new ActiveXObject("microsoft.xmldom")
xmlDoc.async=false
xmlDoc.load("fdroid.xml")
root=xmlDoc.documentElement
newHTML=""
buildTree(root);
document.getElementById("content").innerHTML=newHTML
}
function buildTree(passedNode){
var children = passedNode.childNodes.length
for (var j=0; j<children; j++){
Node=passedNode.childNodes.item(j)
if (Node.nodeName=="application"){ newHTML+="<P>"+Node.nodeName+" "+j }
if (!Node.hasChildNodes()){
if(Node.parentNode.nodeName == "name"){
newHTML+=( "<BR><B>"+Node.parentNode.nodeName+":</B> "+Node.text )}
else if (Node.parentNode.nodeName =="icon"){
newHTML+="<img src=" +Node.text +">" }
}
buildTree(Node)
}
}
window.onload = start;
</SCRIPT>

  </div>
  <div class="story">
    <h3>Story Title</h3>
    <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed aliquam sem ut arcu. Phasellus sollicitudin. Vestibulum condimentum facilisis nulla. In hac habitasse platea dictumst. Nulla nonummy. Cras quis libero. Cras venenatis. Aliquam posuere lobortis pede. Nullam fringilla urna id leo. Praesent aliquet pretium erat. Praesent non odio. Pellentesque a magna a mauris vulputate lacinia. Aenean viverra. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aliquam lacus. Mauris magna eros, semper a, tempor et, rutrum et, tortor. </p>
    <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed aliquam sem ut arcu. Phasellus sollicitudin. Vestibulum condimentum facilisis nulla. In hac habitasse platea dictumst. Nulla nonummy. Cras quis libero. Cras venenatis. Aliquam posuere lobortis pede. Nullam fringilla urna id leo. Praesent aliquet pretium erat. Praesent non odio. Pellentesque a magna a mauris vulputate lacinia. Aenean viverra. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aliquam lacus. Mauris magna eros, semper a, tempor et, rutrum et, tortor. </p>
  </div>
</div>
<!--end content -->
<div id="navBar">
  <div id="search">
    <form action="#">
      查找您想要的应用
      <input name="searchFor" type="text" size="10" />
      <input name="goButton" type="submit" value="搜索" />
    </form>
  </div>
  <br><br><br>
  <div class="relatedLinks">
    <ul>
      <li class="STYLE2">
        <div align="center"><a href="index.html">首页</a></div>
      </li>
      <li class="STYLE2">
        <div align="center"><a href="hot.html">热门</a></div>
      </li>
      <li>
        <div align="center"><span class="STYLE2"><a href="fashion.html">趋势</a></span></div>
      </li>
      <li></li>
    </ul>
    <br><br><br>
  </div>
  <div class="relatedLinks">
    <h3 align="center" class="STYLE2">分类</h3>
    <ul>
      <li class="STYLE3">
        <div align="center"><a href="sports.html">体育</a></div>
      </li>
      <li class="STYLE3">
        <div align="center"><a href="tool.html">工具</a></div>
      </li>
      <li class="STYLE3">
        <div align="center"><a href="communication.html">通信</a></div>
      </li>
      <li>
        <div align="center"><span class="STYLE3"><a href="life.html">生活</a></span></div>
      </li>
      <li></li>
    </ul>
  </div>

</div>
<!--end navbar -->
<div id="siteInfo"> <img src="" width="44" height="22" /> <a href="#">About Us</a> | <a href="#">Site Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | &copy;2003 Company Name </div>
<br />
</body>
</html>
 
  相关解决方案