admin管理员组文章数量:1421982
I create an error message its working with IE and Mozila. Not woking with Safari, Chrome and Opera.
But I need to use it. Please give me right way for doing it.
<script language="javascript" type="text/javascript">
window.onerror = function(msg, url, line)
{
document.write("Message\t = "+msg + "<br/>Location\t = " + url + "<br/>Line No.\t = " + line + "<br/>Error No.\t = " + this.err.number);
}
this.err = Error(12,"My Own Error");
throw this.err;
</script>
==========================================
Internet Explorer:
My Error
Message = My Own Error
Location = http://localhost/practice/JavaScript/window.errors.php
Line No. = 8
Error No. = 12
================================================
Mozilla FireFox:
My Error
Message = Script error.
Location = My Own Error
Line No. = 0
Error No. = undefined
=====================================================
Safari, Chrome, Opera:
My Error
look the code Mozilla give wrong information. what I do?
I create an error message its working with IE and Mozila. Not woking with Safari, Chrome and Opera.
But I need to use it. Please give me right way for doing it.
<script language="javascript" type="text/javascript">
window.onerror = function(msg, url, line)
{
document.write("Message\t = "+msg + "<br/>Location\t = " + url + "<br/>Line No.\t = " + line + "<br/>Error No.\t = " + this.err.number);
}
this.err = Error(12,"My Own Error");
throw this.err;
</script>
==========================================
Internet Explorer:
My Error
Message = My Own Error
Location = http://localhost/practice/JavaScript/window.errors.php
Line No. = 8
Error No. = 12
================================================
Mozilla FireFox:
My Error
Message = Script error.
Location = My Own Error
Line No. = 0
Error No. = undefined
=====================================================
Safari, Chrome, Opera:
My Error
look the code Mozilla give wrong information. what I do?
Share Improve this question edited Jun 22, 2010 at 12:03 Andy E 345k86 gold badges482 silver badges451 bronze badges asked Jun 22, 2010 at 11:50 Karandeep SinghKarandeep Singh 1,2796 gold badges22 silver badges34 bronze badges 1- 2 (Reference) quirksmode/dom/events/error.html the event is indeed very badly supported on IE and FF; not sure whether there is anything that can be done about it. – Pekka Commented Jun 22, 2010 at 12:08
1 Answer
Reset to default 4Opera doesn't support window.onerror
at all. Chrome supports it, but not on errors that you throw yourself. This is also true of Internet Explorer when using Error objects other than Error()
, e.g. TypeError()
. Chrome also doesn't provide the line and file arguments.
You should correctly catch any exceptions you're going to throw with a try...catch
statement, instead of relying on window.onerror
.
本文标签: error handlingwindowonerror in Safari ( Javascript )Stack Overflow
版权声明:本文标题:error handling - window.onerror in Safari ( Javascript ) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745358479a2655186.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论