解决方案 »
- 系统在ie8上无问题,到ie9上出现输入框无法点击,下拉框需要多选几次等问题
- google map适合企业使用吗?
- |zyciis| 为什么用了事件替换后,this(input)变成了window,谢谢,有代码
- 关于插入文本框的问题,请教高手
- 请问JS变量如何通过FORM传参(急)
- 请教,easyUI中datagrid,在后台获取不到数据就会报错
- setTimeout()函数如何设置自动选择执行自定义的函数?
- 如何获得iframe的水平、垂直滚动条的值!!
- 在jscript中使用asp对象
- 请问document和date对象的区别,谢谢
- 如何用js使网页的窗口图标一闪一闪的?
- cursor:url("") 无法正常使用
<!--
window.onerror = function(){
alert('测试捕获')
return true;
}
var s = function(){
aaalert('error'); // 这是错误
}
s();
//-->
</script>
<script type="text/javascript">
//添加Function原型方法
Function.prototype.trythis = function(){
var args = Array.prototype.slice.call(arguments,0);
try{this.apply(null,args);}catch(e){}
};//任何函数
var hi = function(str){
alert(str);
alert(x);
};//必要的时候调用该方法进行try
hi.trythis('this will be fine!');//不需要的时候直接调用
hi('you will see an error!');
</script>
当然,如果不想污染函数原型对象,可以将trythis函数独立出来作为一个单独运行的函数也可以。