![]() |
Web Development »
Client side scripting »
General
Beginner
License: The GNU General Public License (GPL)
Javascript Error BlockerBy AliSufyanJavascript Error Blocker |
Javascript.NET 1.0, .NET 1.1, .NET 2.0, Win2K, WinXP, Win2003, Vista, .NET 3.0, ASP.NET, WebForms, VS.NET2003, VS2005, Dev
|
||||||||
|
Advanced Search |
|
|
|
||||||||||||||||
This is all about Error Stopping, do not mix it up with Error Blocking. But it does fantastic job in blocking any javascript related errors to come in your web page.
The Story start as i was developing a website. It had extensive use of AJAX and asyncronous calls to web services. The main requirement was to make it cross browser compliant. To do this extensive javascript was used. Now change is a sure thing to come, so it happened. And on some forms, which were working fine, javascript errors start coming. Obviously they were not related to main program. They were coming due to change in website design, addition of fields on some forms. If i have been started to remove those, it could take a year to do so. Then i used the code below and it solved my problems. Now not a single error comes on any of my webpage, and functionality is also working out great.
What we have to do is that just copy the code below in Head or Body section of our webpage. And leave the rest to it. Toggle track_errors to 0 or 1. 0 means Error Blocker is off and 1 means it is on. In the code snippet below i have turned Error blocking to on status.
<script language="javascript"> var track_errors=1; function noError() { if (track_errors==1) { return true; } } window.onerror = noError; </script>
Option above is page level.If you want to make this option global then alternate way is to create a file named validate.js and copy the following code in it:
var track_errors=1;
function noError()
{
if (track_errors==1)
{
return true;
}
}
window.onerror = noError;
and reference it in your page as
<script src="validate.js" type="text/javascript"></script>
One thing to keep in mind is that use it after your development is done. As there may be crucial javascript functions that needs to be tested or included. If error comes in those then you will not be able to track those.
A Great Error Blocker. Works for me everytime. Though a small piece of code. But if you like it, Please do vote for me on this.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 3 Oct 2007 Editor: |
Copyright 2007 by AliSufyan Everything else Copyright © CodeProject, 1999-2009 Web10 | Advertise on the Code Project |