Post by Trill on Aug 23, 2010 19:16:37 GMT -8
These codes modify the default error page displayed when a member attempts to access a broken URL to a thread.
READ FIRST: There are two different versions of this code. Both work very differently and each have their own pros and cons. Essentially, both end up with a similar effect. Do not add both codes to your forum. Pick one or the other, or try them both out separately, and see which one works best to your liking. Please read all the directions before beginning.
EDITING THE CUSTOM ERROR MESSAGE
If you include any ' apostrophes ' in your message, such as to emphasize words or make contractions, you need to precede each apostrophe with a \ slash \. Neither code will work if you include these in your error message without escaping the apostrophe with a slash.
examples: can\'t, doesn\'t, won\'t
Secondly, you cannot include
line
breaks
like
these in your messages. They will break the JavaScript. Instead of pressing Enter or Return on your keyboard, use this: <br />
example: There <br /> is a line break after the word there.
Now, onto the codes:
Option A
If you have any HTML in your main header that you still want to load on error pages, put the following below them in the main header. If you do not have any HTML in your main header that you want displayed on error pages, place the following at the bottom of the global header:
Then, place this code at the TOP of your main or global footer (whichever corresponds to where you placed the header portion of the code):
Pros:
You'll notice that the default message does not load first with this code. This code actually loads before that message normally would on the page, so, essentially, you're seeing this custom error table quicker than you would see the default one.
Cons:
You need both parts of the code to be entered properly to work. This option might be slightly more difficult to edit than the other option.
Option B
<script type="text/javascript">
<!--
// Replace "An Error Has Occurred" Message
// Main Footer
// Trill @ ghbraingle.proboards.com
// Feel free to re-post anywhere, as long as this header stays intact.
var replaceTitle = 'This will be the header of the error message';
var replaceError = 'This will be the explanation. Include <i>any</i> <b>HTML</b> here.';
var td = document.getElementsByTagName("td");
if(pb_action=='display' && document.title.match(/An Error Has Occurred/)){
for(i=0;i<td.length;i++){
if(td.width=="100%" && td.className=="titlebg" && td.innerHTML.match(/An Error Has Occurred/i)){
td.innerHTML = replaceTitle;
td[i+1].innerHTML = replaceError;
}
}
}
//-->
</script>
Pros:
Fairly simple editing. It just goes into your global footer.
The navigation bar remains visible above the error table.
Cons:
This code works slower than the other option. The default error message is displayed first, then replaced with the error message.
READ FIRST: There are two different versions of this code. Both work very differently and each have their own pros and cons. Essentially, both end up with a similar effect. Do not add both codes to your forum. Pick one or the other, or try them both out separately, and see which one works best to your liking. Please read all the directions before beginning.
EDITING THE CUSTOM ERROR MESSAGE
If you include any ' apostrophes ' in your message, such as to emphasize words or make contractions, you need to precede each apostrophe with a \ slash \. Neither code will work if you include these in your error message without escaping the apostrophe with a slash.
examples: can\'t, doesn\'t, won\'t
Secondly, you cannot include
line
breaks
like
these in your messages. They will break the JavaScript. Instead of pressing Enter or Return on your keyboard, use this: <br />
example: There <br /> is a line break after the word there.
Now, onto the codes:
Option A
If you have any HTML in your main header that you still want to load on error pages, put the following below them in the main header. If you do not have any HTML in your main header that you want displayed on error pages, place the following at the bottom of the global header:
<script type="text/javascript">
<!--
// Replace "An Error Has Occurred" Message
// Trill @ ghbraingle.proboards.com
// Feel free to re-post anywhere, as long as this header stays intact.
if(pb_action=='display' && document.title.match(/An Error Has Occurred/)){
document.write(' <br /><table cellpadding="4" cellspacing="1" border="0" width="91%" bgcolor="000000" class="bordercolor" align="center"><tr><td width="100%" class="titlebg" bgcolor="212121"><font size="2"><b> Your Custom Error Title Here </b></font></td></tr><tr><td width="100%" class="windowbg" bgcolor="212121"><font size="2">Place your description in HTML here. Remember to \'escape\' all apostrophes. Also, remember to use the BR tag to break the lines. </font></td></tr></table><div id="errorHide" style="display:none;">');
}
//-->
</script>
Then, place this code at the TOP of your main or global footer (whichever corresponds to where you placed the header portion of the code):
<script type="text/javascript">
<!--
// Replace Error Message by Trill, footer portion
if(pb_action=='display' && document.title.match(/An Error Has Occurred/)){
document.write('</div><br /><br />');
}
//-->
</script>
Pros:
You'll notice that the default message does not load first with this code. This code actually loads before that message normally would on the page, so, essentially, you're seeing this custom error table quicker than you would see the default one.
Cons:
You need both parts of the code to be entered properly to work. This option might be slightly more difficult to edit than the other option.
Option B
<script type="text/javascript">
<!--
// Replace "An Error Has Occurred" Message
// Main Footer
// Trill @ ghbraingle.proboards.com
// Feel free to re-post anywhere, as long as this header stays intact.
var replaceTitle = 'This will be the header of the error message';
var replaceError = 'This will be the explanation. Include <i>any</i> <b>HTML</b> here.';
var td = document.getElementsByTagName("td");
if(pb_action=='display' && document.title.match(/An Error Has Occurred/)){
for(i=0;i<td.length;i++){
if(td.width=="100%" && td.className=="titlebg" && td.innerHTML.match(/An Error Has Occurred/i)){
td.innerHTML = replaceTitle;
td[i+1].innerHTML = replaceError;
}
}
}
//-->
</script>
Pros:
Fairly simple editing. It just goes into your global footer.
The navigation bar remains visible above the error table.
Cons:
This code works slower than the other option. The default error message is displayed first, then replaced with the error message.