Forum Moderators: open
I Have 2 different stylesheets for a particular HTML page and i want to allow the user to select the particular stylesheet he wants to use while opening the HTML page. I have a pop-up box prompting the user to select the stylesheet. How to apply this to the HTML page?
In the below example i am hardcoding teh css name viz Flexblue.css but i have 2 stylesheets namely Flexblue and flexbrown. And i want the user to select the stylesheet when loading the HTML. Please advise..
<body>
<div id="Header" style="display:block; float:left; width:100%; clear:both;" >
<img src="ToolImages/Oracle.gif" alt="Oracle Logo" style="float:left" >
</div>
<div class="tabber" id="tab1">
<div class="tabbertab">
<h2><a name="tab1">Templates</a></h2>
<div class="tabber" id="tab1-1">
<div class="tabbertab">
<h3>Landing Page</h3>
<textarea class="HTMLArea" name="EditLandingPage" >
<link href="Theme/Flexblue.css" rel="stylesheet" type="text/css">
PS. Actual code will be very helpful as i am very new to Javasdcripting and do not have much hands on experience...
Thanks in advance for your kindness...
var docHead = document.getElementsByTagName("head")[0];
// remove first link tag in head
docHead.removeChild(docHead.getElementsByTagName("link")[0]);
// create a new link tag to append
var newScript = document.createElement("link");
newScript.rel = "stylesheet";
newScript.type = "text/css";
newScript.href = "myStyles.css";
// add the new tag to the end of the head
docHead.appendChild(newScript);
Wondering if changing href of existing would also work