天天看點

IE8 相容性問題

IE8 相容性問題

設定script标簽内容

在IE8中,下面的代碼報錯:

$('#invoiceListDot').text(htmlTemplate);
           
IE8 相容性問題

說明:invoiceListDot 是一個script标簽

<script id="invoiceListDot" type="text/x-dot-template">  
               {{? it.invoiceInfoDtos}}  
               {{ for(var prop=0;prop  
               <it.invoiceInfoDtos.length  
                       ; prop++){ }}  
                       {{? it.invoiceInfoDtos[prop]}}  
               <div class="{{ if(prop==0 && it.create==true){}}invoice-infor {{ }else {}}no-invoice{{ }}}"  
                    data-index="{{= prop }}">  
                   <span class="no-ivoice-icon"></span>  
                   <span>普通發票</span>  
                   <span class="ivo-margin invoiceType">{{= it.invoiceInfoDtos[prop].content }}</span>  
                   <span class="ivo-margin invoiceCompany">{{= it.invoiceInfoDtos[prop].title }}</span>  
                   <span class="ivo-margin invoiceAddress">{{= it.invoiceInfoDtos[prop].address }}</span>  
                   <span class="ivo-margin invoicePerson">{{= it.invoiceInfoDtos[prop].receiver }}</span>  
                   <span class="ivo-margin invoicePhone">{{= it.invoiceInfoDtos[prop].phone }}</span>  
               </div>  
               {{?}}  
               {{ } }}  
               {{?}}  
           </script>  
           

改為如下代碼也報錯:

$('#invoiceListDot').html(htmlTemplate);
           

這是IE8的相容性問題.

解決方法:

在js中判斷浏覽器類型,若是IE8,則執行

$('#invoiceListDot').innerHTML = htmlTemplate; 
           

整個邏輯判斷如下:

if (getBrowserVersion.isIE8) {  
       $('#invoiceListDot').innerHTML = htmlTemplate;  
   } else {  
       $('#invoiceListDot').text(htmlTemplate);  
   }                  
IE8 相容性問題

擷取script标簽的内容的時候:

IE8 相容性問題
var tmplate = $invoiceListDot.text();//IE8中傳回空字元串  
                   if (!tmplate) {  
                       console.log('$invoiceListDot.text() return null');  
                       tmplate = $invoiceListDot.html();  
                   }                  

IE識别不了有空格的json

比如

{

“path”:”huang wei”

}

IE7中動态建立表格時,必須要建立tbody,否則表格不顯示

var tb = put('table.service');  
if (BrowserVersion.isIE7 || BrowserVersion.isIE6) {  
                tb=put(tb,'tbody');  
             } 
           

設定2x背景圖檔IE8中不顯示

IE8 相容性問題

有問題的css樣式:

background: rgba(, , , ) url("../imgs/placeOrder/[email protected]_org.png") no-repeat scroll  ;
  background-image: -webkit-image-set(url(../imgs/placeOrder/icon_select_l@1x_org.png)  x, url(../imgs/placeOrder/icon_select_l@2x_org.png) x);
  background-image: -moz-image-set(url(../imgs/placeOrder/icon_select_l@1x_org.png) x, url(../imgs/placeOrder/icon_select_l@2x_org.png) x);
  background-image: -ms-image-set(url(../imgs/placeOrder/icon_select_l@1x_org.png) x, url(../imgs/placeOrder/icon_select_l@2x_org.png) x);
  background-image: -o-image-set(url(../imgs/placeOrder/icon_select_l@1x_org.png) x, url(../imgs/placeOrder/icon_select_l@2x_org.png) x);
           

改為:

IE8 相容性問題

li 标簽的value屬性

html li标簽設定value詭異的問題

設定html标簽的自定義屬性