切換 style / Styles Switcher
切換 style 的原理是藉由以javascript disable 現在的 style,並
enable 想要用的 style 而達成。如下:
First disable the current style. And then enable the style you want to use.
See below:
var link = document.getElementsByTagName("link");
link[style_to_disable] = flase;
link[style_to_enable] = true;
詳細的範例如下:
following is the detail:
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylea.css"/>
<link rel="stylesheet" type="text/css" href="styleb.css"/>
</head>
<body>
<script type="text/javascript">
var cur = 1;
function tryit()
{
var link = document.getElementsByTagName("link");
link[cur].disabled = true;
link[1-cur].disabled = false;
cur = 1-cur;
</script>
</body>
</html>
(Opera 7.23 compatible)