簡體   English   中英

Internet Explorer 8,9,10 javascript無法正確加載

[英]Internet Explorer 8, 9, 10 javascript not loading correctly

我目前在我的測試頁面上有一個工作的“經銷商定位器”,可以在頁面的右側找到

http://www.khl.com/dev/american-cranes-and-transport/

盡管IE11似乎有效,但除了可怕的IE之外,它的工作正常。

當您在IE中查看頁面時,您會看到一個看起來很糟糕的掌上電腦圖像,這是因為JS看起來像這樣:

<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/'; 
ImgPreloadAry=new Array('placeholder.jpg','link3.png','sany3.png','manitex3.png','manitowoc3.png'); 
SRCAry=new Array(); 

for (i=0;i<ImgPreloadAry.length;i++){ 
 SRCAry[i]=new Image(); 
 SRCAry[i].src=ImgPath+ImgPreloadAry[i]; 
} 

function Cng(sel){ 
 document.getElementById('img').src=ImgPath+sel.options[sel.selectedIndex].value; 
 document.getElementById('tbl').style.backgroundImage='url('+(ImgPath+sel.options[sel.selectedIndex].value)+')'; 
} 



var ImgPath='http://www.khl.com/other_files/khl/locate/';
var linksArray = [
  { Img: 'placeholder.jpg', Link : '#', RelatedText :'TEST LINK'},
  { Img: 'link3.png', Link : 'http://www.linkbelt.com/', RelatedText :'Link-belt description and link'},
  {Img:'sany3.png', Link : 'http://www.sanygroup.com/', RelatedText :'Sanny description and link'},
  {Img:'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.'},
  {Img:'manitowoc3.png', Link : 'http://www.manitowoc.com/',RelatedText : 'Manitowoc description and link'},
];

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 = ImgPath + linksArray[selectedIndex].Img;
}




//--> 
</script> 
</head> 

有效地ImgPath =' http: //www.khl.com/other_files/khl/locate/由於某種原因,IE認為這也是一個圖像(不是路徑)。

有什么明亮的火花可以幫助我嗎?

親切的問候,山姆

經典trailling逗號bug。

.....towoc description and link'},
                                ^^^
                   this comma is invalid and will break your JS in IE.

如果你通過像JSHint這樣的驗證器運行你的JS代碼,你會被警告這樣的問題。 如果你使用一個不錯的IDE來編輯代碼,它們也很容易被發現,因為你也會從中獲得語法高亮和警告。

另外,你已經聲明了function Cng()兩次,這顯然是錯誤的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM