如何为firefox使用setTimeout或focus方法。 [英] How to use setTimeout or focus method for firefox.
本文介绍了如何为firefox使用setTimeout或focus方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Firefox 34.0.5
我已尝试过setTimeout和焦点但它在firefox中无效,但谷歌浏览器和IE浏览器都可以。我也清除了浏览器缓存。我正在使用以下javascript函数...
I am using Firefox 34.0.5
I have tried both setTimeout and focus but it is not working in firefox but all ok with google chrome and IE. I also have cleared browser cache.I am using the following javascript function...
function NonNumericAlert(Id) {
controls = document.getElementById(Id);
if (controls.value != Number(controls.value)) {
alert("Field(s) should be numeric only.");
//this.controls.focus();
//setTimeout(controls.focus(), 1);
//setTimeout(controls.select, 1);
//setTimeout("controls.focus();", 50);
setTimeout("this.controls.focus();", 0);
alert("jhghaghsgh");
return false;
}
}
推荐答案
确定通过使用此解决方案..
ok its solved by using this..
function NonNumericAlert(Id) {
controls = document.getElementById(Id);
if (controls.value != Number(controls.value)) {
alert("Field(s) should be numeric only.");
setTimeout("this.controls.select();", 0);
setTimeout("this.controls.focus();", 0);
return false;
}
}
这篇关于如何为firefox使用setTimeout或focus方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文