User Tools

Site Tools


custom-error-page

Custom error pages

Create custom html pages that will be displayed when a load error occurs.

NOTE: This requires uzbl experimental!

Uzbl configuration

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')\@

Script

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>#'

Template

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>
custom-error-page.txt · Last modified: 2016/08/31 14:10 (external edit)