您现在的位置是:首页 > 电脑技术查询 > web开发

一段JS在IE下能正常使用,到FIREFOX下失效解决思路

编辑:chaxungu时间:2022-10-02 23:22:52分类:web开发

一段JS在IE下能正常使用,到FIREFOX下失效
<script language= "JavaScript " type= "text/JavaScript ">
<!--
function check_cart(){
var temp_customer_id;
temp_customer_id = " ";
if (temp_customer_id == "39 "){
location.href= "login.php?origin=checkout_shipping.php ";
}

if (Number(cart_quantity.hongli_post.value) > 180){
alert( "您輸入的紅利大於您所擁有的紅利點數,請重新輸入 ");
cart_quantity.hongli_post.focus();
return false;
}
var hl=cart_quantity.hongli_post.value;

location.href( "http://krusell.works.tw/checkout_shipping.php?hongli22= "+hl);
}
//-->
</script>

------解决方案--------------------
location.href = "http://krusell.works.tw/checkout_shipping.php?hongli22= "+hl;
------解决方案--------------------
Expressions can be used in place of the preceding value(s), as of Microsoft&reg; Internet Explorer 5. For more information, see About Dynamic Properties.


------解决方案--------------------
一个是href:

IE或者Firefox2.0.x下,可以使用window.location或window.location.href;Firefox1.5.x下,只能使用window.location

另一个是cart_quantity.hongli_post
建议用document.getElementById( "hongli_post ")
------解决方案--------------------
try:

<script language= "JavaScript " type= "text/JavaScript ">
<!--
function check_cart(){
var temp_customer_id;
temp_customer_id = " ";
if (temp_customer_id == "39 "){
location= "login.php?origin=checkout_shipping.php ";
}

if (Number(document.getElementById( "hongli_post ").value) > 180){
alert( "您輸入的紅利大於您所擁有的紅利點數,請重新輸入 ");
document.getElementById( "hongli_post ").focus();
return false;
}
var hl=document.getElementById( "hongli_post ").value;

location= "http://krusell.works.tw/checkout_shipping.php?hongli22= "+hl;
}
//-->
</script>