用于Bigcommerce购物车的Javascript在IE中不起作用

用于Bigcommerce购物车的Javascript在IE中不起作用,javascript,bigcommerce,Javascript,Bigcommerce,下面的JS脚本(非常简单,不是很好)正在我客户的一个Bigcommerce Cart中使用。它的设计目的是拾取给定的BC客户组,并检查给定元素(单选按钮)的状态,然后显示给定的选择器,或者让它保持隐藏状态。它在除IE以外的所有浏览器中都可以正常工作,但即使控制台没有显示错误,也不会显示选择器。(为什么它以1秒的间隔运行?因为BC一次装载四件行李,但来自同一页面。哇!) 这里有没有IE不支持的JS函数?我已经检查了所有的函数,但我什么都没看到,但是你知道如果你盯着同一个代码看几个小时,你会变得多么

下面的JS脚本(非常简单,不是很好)正在我客户的一个Bigcommerce Cart中使用。它的设计目的是拾取给定的BC客户组,并检查给定元素(单选按钮)的状态,然后显示给定的选择器,或者让它保持隐藏状态。它在除IE以外的所有浏览器中都可以正常工作,但即使控制台没有显示错误,也不会显示选择器。(为什么它以1秒的间隔运行?因为BC一次装载四件行李,但来自同一页面。哇!)

这里有没有IE不支持的JS函数?我已经检查了所有的函数,但我什么都没看到,但是你知道如果你盯着同一个代码看几个小时,你会变得多么盲目

[编辑:IE似乎正在提取脚本中的关键短语,尽管innerText不应该这样做。但至少我离解决方案更近了一步!]

<script>
window.onload = setInterval(hideCC, 1000);

function hideCC ()
 {
/* Hide CC payment option for below listed groups only */
/* Add new customer groups with comma-separated list (i.e. [39,42,87]) */
var customergroup = [27,32,22,65,2,69,72,74,79,78,87,84,60,61,52,53,54,55,56,57,58,59,62,63,70,83,8,5];
/* Hide CC payment option for those using International Freight */
var intlFreight = document.documentElement.innerText.indexOf('International Freight');
/* Check state of wire transfer button; if it's checked, we don't need to do any of this */
var wireChecked = document.getElementById("radio-bankdeposit").checked;
if (wireChecked == true) {
    return;
}
else {
/* If the customergroup belongs to one of those listed above OR the text "International Freight" appears on the page, that will trigger this if */
if(customergroup.indexOf({{{customer.customer_group_id}}}) > -1 || intlFreight > -1 ) { 
/* console.log({{{customer.customer_group_id}}}); */
document.querySelector("#micro-app-ng-checkout > div > div > main > ol > li.checkout-step.checkout-step--payment.optimizedCheckout-checkoutStep > div.checkout-view-content > form > fieldset:nth-child(1) > div > ul > li.form-checklist-item.optimizedCheckout-form-checklist-item.form-checklist-item--selected.optimizedCheckout-form-checklist-item--selected").style.display="none"; 
}
}
};
</script>

window.onload=setInterval(hideCC,1000);
函数hideCC()
{
/*仅对以下列出的组隐藏抄送付款选项*/
/*添加带有逗号分隔列表的新客户群(即[39,42,87])*/
var customergroup=[27,32,22,65,2,69,72,74,79,78,87,84,60,61,52,53,54,55,56,57,58,59,62,63,70,83,8,5];
/*为使用国际运费的用户隐藏抄送付款选项*/
var intlFreight=document.documentElement.innerText.indexOf(“国际货运”);
/*检查电汇按钮的状态;如果已检查,则不需要执行任何操作*/
var wireChecked=document.getElementById(“无线银行存款”).checked;
如果(wireChecked==true){
返回;
}
否则{
/*如果customergroup属于上面列出的其中一个,或者页面上出现文本“国际货运”,则在以下情况下会触发此操作:*/
if(customergroup.indexOf({{{customer.customer_group_id}}}})>-1{
/*log({{{{customer.customer\u group\u id}}})*/
document.querySelector(“#micro-app ng checkout>div>div>main>ol>li.checkout-step.checkout-step--payment.optimizedCheckout-checkoutStep>div.checkout-view-content>form>fieldset:n子项(1)>div>ul>li.form checklist item.optimizedCheckout form checklist item.form checkout item--selected”).style.display=“无”;
}
}
};

以下是jQuery版本的“shippingOption desc”类中的字符串检查。希望这能解决IE和innerText的问题:)


你正在测试哪个版本的IE?在IE开发工具中检查控制台时有错误吗?我正在使用IE11进行测试,我相信我已经发现了问题:尽管使用了innerText(这应该可以避免),IE在脚本本身中使用了“国际货运”,并触发了if。理想情况下,我想做的是只在类中查找字符串“shippingOption desc”,但是代码
var intlfreeght=document.getElementsByClassName(“shippingOption desc”).innerText.indexOf('International Freight');
显然不是正确的方法,尽管(或者可能是因为)我无法找到正确的方法清晨几个小时清理堆栈溢出。:)使用jQuery是一个选项吗?还是解决方案需要香草javascript?令人高兴的是,jQuery绝对是一个选项!世界上没有足够的升级票!谢谢你,Karen White,这工作得很好!
var intlFreight = $('.shippingOption-desc').text().indexOf('International Freight');