Switching Stylesheets with Javascript

Javascript stylesheet switchers:

Change stylesheet using the document.styleSheets object: Red Blue

Change stylesheet using the document.getElementsByTagName("link") method: Red Blue

Test cases:

Embedded stylesheet test

The colour of this <div> is determined by the embedded stylesheets. It should change colour when you change the stylesheet (but only the document.styleSheets method will in fact work).

Linked persistent stylesheet test

The colour of this <div> is determined by a linked persistent stylesheet -- it should always be yellow.

Embedded persistent stylesheet test

The colour of this <div> is determined by an embedded persistent stylesheet -- it should always be lime.