XML文件大体如下:
<div id="name">
<div id="slider">
<div onclick="aa();" class="slide">
<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt="">
<div class="text">
<span class="title">The best</span> The offspring of a customized
orbiter, O飇ostem arose as the best balanced home for our plans.
So we submitted to its conditions. </div>
</div>
</div>
</div>
我想在另外的页面调用其中的ID为slider的DIV 标签,怎么调用是最不耗CPU,内存,和物理空间资源的?
<div id="name">
<div id="slider">
<div onclick="aa();" class="slide">
<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt="">
<div class="text">
<span class="title">The best</span> The offspring of a customized
orbiter, O飇ostem arose as the best balanced home for our plans.
So we submitted to its conditions. </div>
</div>
</div>
</div>
我想在另外的页面调用其中的ID为slider的DIV 标签,怎么调用是最不耗CPU,内存,和物理空间资源的?
如果是htm,然后打开另一个页面,那么可以根据获取对象的方式来获得
可以直接将这段代码提取出来放在一个页面中
要用这段代码的地方直接include
这样耗的资源最少
我是在页面上调用解析一个XML文件。
你能把方法说具体点不,我新手啊
<div id="slider">
<div onclick="aa();" class="slide">
<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt="">
<div class="text">
<span class="title">The best </span> The offspring of a customized
orbiter, O飇ostem arose as the best balanced home for our plans.
So we submitted to its conditions. </div>
</div>
</div>如果想在b.jsp中使用
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>b.jsp</title>
</head><body>
b.jsp页面内容
b.jsp页面内容
....
<jsp:include flush="true" page="a.jsp"></jsp:include>
....
b.jsp页面内容
b.jsp页面内容
</body></html>
你这是一个JSP页面的调用啊,和XML文件调用不同吧?
一定要用xml的话,没有其他捷径,参考1L的方法
<div onclick="aa();" class="slide">
<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt="">
<div class="text">
<span class="title">The best </span> The offspring of a customized
orbiter, O飇ostem arose as the best balanced home for our plans.
So we submitted to its conditions. </div>
</div>
</div>如果想在b.jsp中使用 HTML code<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>b.jsp</title>
</head><body>
b.jsp页面内容
b.jsp页面内容
....
<jsp:include flush="true" page="a.jsp"></jsp:include>
....
b.jsp页面内容
b.jsp页面内容
</body></html>
<div id="slider">
<div onclick="aa();" class="slide">
<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt="">
<div class="text">
<span class="title">The best </span> The offspring of a customized
orbiter, O飇ostem arose as the best balanced home for our plans.
So we submitted to its conditions. </div>
</div>
</div>这部出来吗还是里面的?下面假设你是字符串的。var xml='<div id="name">'
+'<div id="slider">'+
'<div onclick="aa();" class="slide">'+
'<img class="diapo" src="http://worm.bluesfear.com/11.jpg" alt=""/>'+//注意,你这里img没有闭合,必须完全符合xml规定
'<div class="text">'+
'<span class="title">The best </span> The offspring of a customized'+
'orbiter, ostem arose as the best balanced home for our plans.'+
'So we submitted to its conditions. </div>'+
'</div>'+
'</div></div>',dom,isIE=false;
if(window.ActiveXObject){
dom=new ActiveXObject("microsoft.xmldom");
dom.loadXML(xml);
isIE=true;
}
else if(window.DOMParser){//ff
dom=new DOMParser().parseFromString(xml,'text/xml');
}
var dv=dom.getElementsByTagName("div");
if(isIE)alert(dv[1].xml);
else if(window.XMLSerializer) alert(new XMLSerializer().serializeToString(dv[1]));
XML文件,就引用部分,不是全部。
谢谢你