Friday, August 1, 2014

How to change Style of a HTML page at run time

It is simply disabling and enabling different style tag at run time.
Say there are two themes represented by styleSheets[0]  (GREEN) & styleSheets[1] (BLUE)

<script> 
function removeStyles() {
document.styleSheets[0].disabled = true; 
document.styleSheets[1].disabled = true; 

}

function applyGreenStyle() {
removeStylesStyles()
document.styleSheets[0].disabled = false; 
}

function applyBlueStyle() {
removeStylesStyles()
document.styleSheets[1].disabled = false; 
}
</script> 



No comments:

Post a Comment