我的脚本昨晚工作正常,今天早上它没有完成整个变量路径。对于href链接和图像src标记,它停在 - 。例如,图像页面是" /iwov-resources/images/image.jpg"它写了" / iwov"。
这不是在Chrome中发生的,只有IE。我确实通过更新我的路径没有连字符来解决这个问题,但这是一个乐队援助。
之前有没有人遇到过这个问题?
这是我的代码:
function loadSlice() {
var path = '/templatedata/local/OpcoSliceTeaser/data/SliceTeaser.xml';
if (window.XMLHttpRequest)
{ xmlhttp=new XMLHttpRequest(); }
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",path,false);
xmlhttp.send();
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var colHead;
var header;
var headertext;
var colText;
var imgPath;
var myImg;
var imgAlt;
var myAlt;
var headline;
var myHeadline;
var teaser;
var teaserText;
var moreText;
var myMoreText;
var moreLink;
var myMoreLink;
colHead=xmlhttp.responseXML.documentElement.getElementsByTagName("imagecontainer");
colText=xmlhttp.responseXML.documentElement.getElementsByTagName("Textcontainer");
for (var i=0;i<colHead.length;i++)
{
header=colHead[i].getElementsByTagName("HeaderText");
headertext = header[0].firstChild.nodeValue;
moreText =colHead[i].getElementsByTagName("MoreText");
myMoreText = moreText[0].firstChild.nodeValue;
moreLink =colHead[i].getElementsByTagName("MoreLinkURL");
myMoreLink = moreLink[0].firstChild.nodeValue;
}
for (var i=0;i<colText.length;i++)
{
imgPath=colText[i].getElementsByTagName("ImgPath");
myImg = imgPath[0].firstChild.nodeValue;
imgAlt= colText[i].getElementsByTagName("ImgAltText");
myAlt = imgAlt[0].firstChild.nodeValue;
headline = colText[i].getElementsByTagName("HeadlineText");
myHeadline = headline[0].firstChild.nodeValue;
teaser = colText[i].getElementsByTagName("TeaserText");
teaserText = teaser[0].firstChild.nodeValue;
}
var navtxt;
navtxt = '<div class="subHeadline_wrapper"><h4><a target="" href="' + myMoreLink + '">';
navtxt = navtxt + headertext;
navtxt = navtxt + "</a></h4></div>";
navtxt = navtxt + '<div class="image_wrapper center"><a target="" href="' + myMoreLink + '">' + '<img src="' + myImg + '" border="0" alt="' + myAlt + '"/></a></div>';
navtxt = navtxt + '<div class="container"><div class="headline_wrapper"><h3><a target="" href="' + myMoreLink + '">' + myHeadline + '</a></h3></div>';
navtxt = navtxt + '<div class="text_wrapper">' + teaserText + '</div></div>';
navtxt = navtxt + '<div class="more-link-wrapper"><a target="_self" href="' + myMoreLink + '"><span>' + myMoreText + '</span></a></div>';
document.getElementById("APCslice").innerHTML = navtxt ;
}
}
这是我的传递正常的xml:
<root>
<imagecontainer>
<Style>Mini Col</Style>
<HeaderText>POWER</HeaderText>
<Textcontainer>
<ImgPath>/images/Security_Series_APCSlice.jpg</ImgPath>
<ImgAltText>Security team has extensive industry experience</ImgAltText>
<HeadlineText>Security team has extensive industry experience</HeadlineText>
<TeaserText>
<p>Powerlines today introduces “The 101” series, providing a general overview of company departments, such as Security, Hydro and Distribution.</p>
</TeaserText>
</Textcontainer>
<MoreText>More Powerlines</MoreText>
<MoreLinkURL>http://sotoday.southernco.com/apc/</MoreLinkURL>
</imagecontainer>
<Vpath/>
</root>
但是如果我的图片路径或链接是:
<ImgPath>/images/Security-Series-APCSlice.jpg</ImgPath>
它只写&#34; / images / Security&#34;
此外,如果有人有任何关于如何简化这一点的提示,以使它更快,那将是非常有用的,谢谢所有!