我有一些代码充当重定向并在用户单击单选按钮时设置一些值。在 Chrome 和 Firefox 中,这些脚本可以完美运行,但在 IE 中似乎什么也没有发生。
HTML
<td>
<input type='radio' id="order_type6" name='order_type' value="5"
onClick="selectOrderType('1')">
<label for="order_type6"><strong>Facility Employee</strong></label>
</td>
<td>
<input type='radio' id="order_type7" name='order_type' value="5"
onClick="selectOrderType('1')">
<label for="order_type7"><strong>Private Contract</strong></label>
</td>
JS函数:
function selectOrderType(type)
{
console.log(type);
//replace '&load=1' with '&neworder=1'
$location = window.location.href.replace(/&load\=1/,'&neworder=1#');
//replace '#' at the end of the string with '' + $ordertype
window.location.href = $location.replace(/#?$|&order_type\=\D?/,'&order_type='+type);
}
最佳答案
删除console.log - 或按F12 打开控制台。
IE不打开的话不支持console
'console' is undefined error for Internet Explorer
或者更改为window.console && console.log(type)
关于javascript 无法在 IE 中使用单选按钮 onClick 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12863498/