I am wanting to set up a site that has different stylesheets attached, when someone clicks a link, a different stylesheet is loaded. Can this be done in JacaScript, if so how would I go about it? Also is Javascript the best method for this?
var oLink = document.createElement("link") oLink.href = "mypath/mycss.css"; oLink.rel = "stylesheet"; oLink.type = "text/css"; document.body.appendChild(oLink); Code (markup): OR if (document.layers) { document.write('<link rel=stylesheet href="nn4.css">') } else { document.write('<link rel=stylesheet href="main.css">') } Code (markup):