...

View Full Version : Mulitple Custom Error Messages



Skyzyx
08-23-2002, 10:22 PM
I have designed a custom error message box for one of my websites. I have set it up, so that if there is an error on the page, it will trigger a script that opens a new window... etc.

Here is an example:


function errorReport()
{
var errorContent=''; // To clear the variable.

errorContent+='<html><body>';
errorContent+='This Is My Error Message<br>';
errorContent+='</body></html>';

var errWin=window.open('', 'errorWindow', 'width=650,height=300');
errWin.document.write(errorContent);
errWin.focus();
}

window.onerror=errorReport;


This part works all fine and dandy.

The problem is that if I have 2 errors on a single page, the error message window will double-draw. If I have 3 errors on a single page, it will triple-draw.

My question is, is there a way to only make the error message popup once, regardless of how many errors there are?

For an example, go to www.GoldenRuleProduce.com, and in the location bar type something like:


javascript:document.write('


This will trigger the error message, but it also causes another error to occur, and the error message double-draws.

Any help would be appreciated.

beetle
08-23-2002, 10:51 PM
maybe have a global that is set when onerror fires...and checked too

var errorOnce = 0;
function errorReport()
{
if (errorOnce) return;
errorOnce = 1;
var errorContent=''; // To clear the variable.

errorContent+='<html><body>';
errorContent+='This Is My Error Message<br>';
errorContent+='</body></html>';

var errWin=window.open('', 'errorWindow', 'width=650,height=300');
errWin.document.write(errorContent);
errWin.focus();
}

window.onerror=errorReport;

knguyen99
08-23-2002, 11:02 PM
Passing an argument to your function where the errorMsg is combining of all your errors.

1) Declare a variable
var error = false;

2) When error happenedand set it to TRUE
error = true;
errorMsg = "your first error"

3) If you get a second error
errorMsg = errorMsg + "second error";

4) Call the errorReport at the end
if (error)
errorReports(errorMsg);




function errorReport(errorMsg)
{
var errorContent=''; // To clear the variable.

errorContent+='<html><body>';
errorContent+=errorMsg<br>';
errorContent+='</body></html>';

var errWin=window.open('', 'errorWindow', 'width=650,height=300');
errWin.document.write(errorContent);
errWin.focus();
}

window.onerror=errorReport;

Skyzyx
08-24-2002, 03:33 AM
Thanks guys. Actually, beetle's idea is what I want to work with. I'll give it a try. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum