我現在正在發佈完整的代碼,請檢查並讓我知道我必須在此代碼中修改以解決此問題問題在IE:SCRIPT5007:無法獲取屬性'indexOf'的值:對象爲null或undefined.Please幫助解決此問題
var values = [];
$("#tblitem #itm").each(function(a, b)
{
values[a] = b.text;
});
valuex [X]用於取ITEMNAME here.and下面我用它在的indexOf()的indexOf()工作良好之前我使用array.problem使用陣列之後發生。只在IE中。
var compare_value_oldd="$500";
var compare_value_neww=parseFloat(compare_value_oldd.replace(/[^0-9-.]/g,''));
for(var x in values)
{
if (parseFloat(totalnumm.replace(/[^0-9-.]/g,'')) > compare_value_neww && values[x].indexOf("Custom") > -1)
{
if ($.cookie('test_status1') != '2')
{
$('#element_to_pop_up1').bPopup({
content: 'image', //'ajax', 'iframe' or 'image'
contentContainer: '.content',
loadUrl: 'coupon.jpg'
});
<!--cookie settings here-->
<!--expire time of cookie is 30 days.you can change it as per your requirements-->
$.cookie('test_status1', '2', { expires: 30 });
}
}
}
我在這一行發生錯誤。
**if (parseFloat(totalnumm.replace(/[^0-9-.]/g,'')) > compare_value_neww && values[x].indexOf("Custom") > -1)**
採取看看http://stackoverflow.com/questions/1744310/how-to-fix-array-indexof-in-javascript-for-ie-browsers – anderssonola
因此值[x]爲空或未定義 –
嗨soderslatt請讓我知道我必須添加jQuery.inArray(value,array [,fromIndex] )??? – honey