Javascript 调用image变量会在IE中留下一个图像占位符
打电话给AllBrightSparks,我遇到了一些问题,我找不到这个bug修复程序。它在Firefox、Chrome和IE11上都能完美工作,但IE11下的任何东西都无法工作 附加代码Javascript 调用image变量会在IE中留下一个图像占位符,javascript,html,internet-explorer,Javascript,Html,Internet Explorer,打电话给AllBrightSparks,我遇到了一些问题,我找不到这个bug修复程序。它在Firefox、Chrome和IE11上都能完美工作,但IE11下的任何东西都无法工作 附加代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w
<!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 Codumentt</title>
</head>
<body>
<div class="storeNews">
<img src="http://www.khl.com/other_files/khl/dealer-locatot.png" border="0">
<script language="JavaScript" type="text/javascript">
ImgPath='http://www.khl.com/other_files/khl/locate/placeholder.jpg';
ImgPreloadAry=new Array('http://www.khl.com/other_files/khl/locate/placeholder.jpg', 'http://www.khl.com/other_files/khl/locate/sany3.png','http://www.khl.com/other_files/khl/locate/manitex3.png');
SRCAry=new Array();
for (i=0;i<ImgPreloadAry.length;i++){
SRCAry[i]=new Image();
SRCAry[i].src=ImgPreloadAry[i];
}
function Cng(sel){
var selectedIndex = sel.selectedIndex;
document.getElementById('companyLink').href = linksArray[selectedIndex].Link;
document.getElementById('relatedText').innerHTML= linksArray[selectedIndex].RelatedText;
document.getElementById('relatedImage').src = linksArray[selectedIndex].Img;
}
var ImgPath='http://www.khl.com/other_files/khl/locate/placeholder.jpg';
var linksArray = [
{ Img:'http://www.khl.com/other_files/khl/locate/placeholder.jpg', Link : '#', RelatedText :'TEST LINK'},
{Img:'http://www.khl.com/other_files/khl/locate/sany3.png', Link : 'http://www.sanygroup.com/', RelatedText :'Sanny description and link'},
{Img:'http://www.khl.com/other_files/khl/locate/manitex3.png', Link : 'http://www.khl.com/servlet/file/Manitex%20dealer%20ad.pdf?ITEM_ENT_ID=90292&COLLSPEC_ENT_ID=38&ITEM_VERSION=1&download=1',RelatedText : 'Manitex Locator can be downloaded below.'},
];
//-->
</script>
</head>
<body>
<div class="storeNews">
<table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="302" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="50" ></td>
<td height="50" id="relatedText">Please select from the company from the downdown below</td>
</tr>
<tr>
<td> </td>
<td><a id="companyLink" href="#"> <img id="relatedImage" href="#"></a></td>
</tr>
</table>
<table width="320" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="13" height="31" align="left" valign="top"> </td>
<td width="307" align="left" valign="top"><select name="Sel" size="0" onchange="Cng(this);" >
<option value="http://www.khl.com/other_files/khl/locate/placeholder.jpg">
</option>
<option value="http://www.khl.com/other_files/khl/locate/sany3.png">Sany America</option>
<option value="http://www.khl.com/other_files/khl/locate/manitex3.png">Manitex</option>
</select></td>
</tr>
</table>
<p></td>
</tr>
</table>
</div>
</body>
</html>
测试代码
ImgPath=http://www.khl.com/other_files/khl/locate/placeholder.jpg';
ImgPreloadAry=新数组('http://www.khl.com/other_files/khl/locate/placeholder.jpg', 'http://www.khl.com/other_files/khl/locate/sany3.png','http://www.khl.com/other_files/khl/locate/manitex3.png');
SRCAry=新数组();
对于(i=0;i
请从下面的下拉列表中选择公司
三一美国
曼尼特斯
如果您能将上述代码添加到Dreamweaver之类的工具中,以查看其实际应用,我将不胜感激
实际上,id“RelatedImage”被调用,因为它收集图像路径-但是,因为路径仅定位根图像,所以在早期版本的IE中会出现占位符
如果有人能帮助我,我将非常感激,即使你能帮助我修改它,使每个图像都有一个直接的路径,而不是调用相关的图像id。这一定是一个常见的错误,但我找不到任何解决方案
问候,,
Sam您有两个body操作,请在提交问题之前清理html。