How to determine whether a linked resource loads successfully
<p>I'm using the following JavaScript to dynamically load stylesheets:</p>

<pre><code>function set_stylesheet(name) {
    var link = document.getElementById('userstylelink');
    link.href = link.href.replace(/[^\/]+\.css$/, name + '.css');
}
</code></pre>

<p>Is there any way to determine whether the new CSS file is loaded successfully? If it fails, I'd like to be able to apply a default stylesheet.</p>
