日期:2014-05-16  浏览次数:20357 次

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, to