Posted by Stuart on 11/29/13 11:28
typingcat@gmail.com wrote:
> Hello.
> I know it is possible to change separate elements' style by changing
>
> [element].style=[another style];
>
> But is it possible to set the entire page's stylesheet?
> For example,
> <head>
> <link rel="stylesheet" type="text/css" href="style1.css" />
> </head>
>
> Can I change "style1.css" to "style2.css" using Javascript and make the
> page be changed dynamically?
>
It is possible - something like the following works :
.....
<link rel="stylesheet" href="style1.css" id="stylesheet">
<script type="text/javascript">
function changeStyle() {
document.getElementById('stylesheet').href = 'style2.css';
}
</script>
.....
<input type="button" onclick="changeStyle();"/>
.....
Works in both IE6 & FF - not sure if there's a better way, though?
--
Stuart Brown <stuart@edesign.cc>
http://www.edesign.cc
Navigation:
[Reply to this message]
|