Create custom html pages that will be displayed when a load error occurs.
NOTE: This requires uzbl experimental!
In order to catch load errors we need to attach to uzbl's LOAD_ERROR event. We simply launch a script when the event is raised, which takes the reason of the error as argument and returns pretty formated HTML.
@on_event LOAD_ERROR set inject_html = \@($XDG_DATA_HOME/uzbl/scripts/load-error.sh '%1')\@
The load-error.sh script's purpose is to replace the reason of error in a HTML template file with the one provided by the LOAD_ERROR event.
As you see above we pass the reason of error to he script using the positional parameter %1. The script will now read the HTML template and replace a string ___REASON___ with the passed in error reason.
The load-error.sh script:
#!/bin/sh # # TEMPLATE=/path/to/load-error.html sed -e "s,___REASON___,$1," $TEMPLATE | sed -e 's#\(http.*\) [0-9]:\(.*\)#<span style="color:red">\2:</span> <a href="\1">\1</a>#'
Use the string ___REASON___ somewhere inside the HTML template which will be replaced with the actual reason of error.
<html> <body> <div align="center"> <table border="0"> <tr> <td> <img src="http://uzbl.org/img/uzbl-logo.png"> </td> <td> The page you requested cannot be displayed. </td> </tr> </table> <br> ___REASON___ </div> </body> </html>