调用图像变量会在IE中留下图像占位符

时间:2013-12-03 09:29:00

标签: javascript html internet-explorer

召唤所有明亮的火花,我有一些问题,我找不到这个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.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&amp;COLLSPEC_ENT_ID=38&amp;ITEM_VERSION=1&amp;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>&nbsp;</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">&nbsp;</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>

如果你能将上面的代码添加到类似Dreamweaver的内容中,我真的很感激。看看它的实际效果。

有效地调用id“RelatedImage”,因为它会收集图像路径 - 但是因为路径只是定位根图像,所以占位符出现在早期版本的IE中。

如果有人可以帮助我,我会非常感激,即使你可以帮我修改它,所以每个图像都有一个直接路径,而不是调用relatedImage id。这必须是一个常见的错误,但我无法在任何地方找到解决方案?

此致 萨姆

0 个答案:

没有答案