Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternate stylesheets not showing up under 'View > Page Style' in Firefox

I have the following code:

...
<head>
  <title>Alternative Style Sheet Example for MDC</title>
  <link href="./default.css" rel="stylesheet" type="text/css" title="Default Style">
  <link href="./simple.css" rel="alternate stylesheet" type="text/css" title="Simple">
  <link href="./insane.css" rel="alternate stylesheet" type="text/css" title="Insane">
</head>
...

(from https://developer.mozilla.org/samples/cssref/altstyles/index.html). If I open a local copy of the html file in Firefox, the alternate stylesheets do not show up in Firefox under 'View > Page Style', I can only see 'No Style' and 'Basic Page Style' option. However, if I open the link above, all the stylesheets show up correctly in the selection ('No Style', 'Default Style', 'Simple' and 'Insane'). Also tested in Chrome with Alt CSS extension, same behavior.

How can I make the options visible for the local copy too?

like image 681
loro2 Avatar asked Oct 16 '22 13:10

loro2


1 Answers

It seems if I simply open the local .html files in Firefox, the stylesheet switching doesn't work as expected. However, if I run a webserver and open the same file through localhost, the stylesheet switching does work.

In my case, I ran the following command in the directory with my .html files (with python 2.x):

python -m SimpleHTTPServer 8000

Then after I input localhost:8000 in the Firefox address bar, the stylesheet alternatives showed up correctly under the 'View > Page Styles' menu (opposed to entering file:///{path}/index.html in the address bar).

The solution also works for Chrome and the Alt CSS extension.

like image 144
loro2 Avatar answered Oct 19 '22 01:10

loro2