Thursday September 12, 2002
New Stylesheet Switcher. I'm trying to use the DOM and Javascript to come up with a new stylesheet switcher for this site. Currently, I use Javascript to read a cookie and do a bunch of document.write's to write out the full <style type="text/css">...</style> code. However, I should be able to use the following to simply replace the <style> tag's contents. However, it doesn't work in IE5/Mac :-(. Please notify me if you know why this doesn't work.
<script type="text/javascript">
function switchStyle() {
var current = document.getElementsByTagName("style").item(0);
if (current.hasChildNodes()) { // IE5/Mac returns false, Mozilla returns true
var newStyle =
document.createTextNode("@import url(/skins/sunset/styles/colors-n-fonts.css);");
current.replaceChild(newStyle, current.firstChild);
}
}
</script>
<button type="button" onclick="switchStyle()">switch stylesheet</button>
You can try it out using the button below:
Posted in The Web
at Sep 12 2002, 06:41:50 PM MDT
Add a Comment
Search This Site
Recent Entries
- Secure JSON Services with Play Scala and SecureSocial
- My What's New in Spring 3.1 Presentation
- Twitter's Open Source Summit: Bootstrap 2.0 Edition
- Refreshing AppFuse's UI with Twitter Bootstrap
- 2011 - A Year in Review
- Upgrading AppFuse to Spring Security 3.1 and Spring 3.1
- What have I been working on at Taleo?
- Our Engaging Trip to Paris and Antwerp
- My HTML5 with Play Scala, CoffeeScript and Jade Presentation from Devoxx 2011
- Deploying Java and Play Framework Apps to the Cloud with James Ward