1
将“严格使用”添加到此功能中正在破坏它。具体来说,我试图取消禁用的输入在严格模式下仍处于禁用状态。在这之前定义了csc_popup_in()和csc_popup_out()函数。预先感谢您的任何意见。“使用严格”打破JavaScript功能 - 为什么?
function show_cc(){
document.getElementById('cc_fade').className='none';
var cc_inps = document.getElementById('cc_fade').getElementsByTagName('input');
for(i=0 ; i<cc_inps.length ; i++){
cc_inps[i].disabled=false;
}
document.getElementById('csclnk').onmouseover = function(){csc_popup_in();};
document.getElementById('csclnk').onmouseout = function(){csc_popup_out();};
if(document.getElementById('amex').checked){
document.getElementById('cc_num').maxLength = 15;
document.getElementById('cc_csc').maxLength = 4;
} else {
document.getElementById('cc_num').maxLength = 16;
document.getElementById('cc_csc').maxLength = 3;
}
}
当然,您的JavaScript控制台中报告了错误... – Pointy 2013-04-30 00:07:58
正如Pointy建议的,您应该查找错误。严格模式的一部分好处是,您可能会得到*更多*错误,告诉您代码中存在错误。这是一件好事。 – 2013-04-30 00:23:05
另外,但你有不必要的匿名功能。您可以直接将这些功能分配为处理程序。例如:'document.getElementById('csclnk')。onmouseover = csc_popup_in;' – 2013-04-30 00:24:05