Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unload CSS from webpage

Tags:

javascript

Am wondering how it would be possible to unload a CSS from a page. e.g. In my page I have included a file called a.css. Now I want the user to be able to change the theme, which is CSS driven, thus he/she should be able to unload a.css and then I can load b.css (else they will conflict)

Any idea how to go about this?

like image 943
Alec Smart Avatar asked Oct 21 '09 05:10

Alec Smart


People also ask

How do you unload a CSS file?

css']"). remove(); Obviously, replace fileToRemove. css with the relative path and filename of the file to be unloaded.

Can I download CSS from a website?

Open up the webpage and click File-> Save Page As... and from that prompt select "Web Page, Complete" . Once you've saved this page this downloads a complete version of the html, javascript, css files and images that are referenced in the HTML.


Video Answer


2 Answers

Take the link element and disable it

document.getElementsByTagName('link')[0].disabled = true;  
like image 190
Xinus Avatar answered Sep 20 '22 12:09

Xinus


With jquery, this works:

$("link[href='fileToRemove.css']").remove(); 

Obviously, replace fileToRemove.css with the relative path and filename of the file to be unloaded.

like image 22
Gullbyrd Avatar answered Sep 21 '22 12:09

Gullbyrd