<!DOCTYPE html><htmllang="en"><head><title>How to install the software</title></head><body><h1>How to install the software</h1><p>Thanks for installing AwesomeProject! With AwesomeProject,you can manage your music collection like a wizard.</p><p>But first, we need to install it:</p><pclass="expert reader">You can install AwesomeProject fromsource. Download the tar file, extract it, then run:<code>./configure ; make ; make install</code></p><pclass="novice reader">AwesomeProject is available inmost Linux distributions. Check your graphical package manager and search for AwesomeProject to install it.</p></body></html>
1.
例子中的 HTML 文档没有与之关联的样式表,所以浏览器中会显示所有的段落。
Image of html in black text.
我们可在文档中添加一些简单的样式来为 读者reader、专家expert 或者 初学者novice
<!DOCTYPE html><htmllang="en"><head><title>How to install the software</title><style>.reader {background-color: ghostwhite;}.expert {color: darkred;}.novice {color: darkblue;}</style></head><body><h1>How to install the software</h1>
<script>functionreaderview(audience) { varlist, item; // hide all class="reader" list = document.getElementsByClassName("reader"); for (item = 0; item < list.length; item++) { list[item].style.display = "none"; } // show all class=audience list = document.getElementsByClassName(audience); for (item = 0; item < list.length; item++) { list[item].style.display = "block"; }}</script>
1.
要在 HTML 文档中使用这个 JavaScript,你可以吧这个功能附加到一个按钮上。由于 readerview 函数需要一个听众audience(这应该是相对那个虚拟音乐播放器来说的)作为参数,你可以使用你想查看的听众类别来调用这个函数,可以是读者reader,专家expert 或者 初学者novice
<!DOCTYPE html><htmllang="en"><head><title>How to install the software</title><style>.reader { background-color: ghostwhite; } .expert { color: darkred; } .novice { color: darkblue; } </style></head><body><script>functionreaderview(audience) { varlist, item; // hide all class="reader" list = document.getElementsByClassName("reader"); for (item = 0; item < list.length; item++) { list[item].style.display = "none"; } // show all class=audience list = document.getElementsByClassName(audience); for (item = 0; item < list.length; item++) { list[item].style.display = "block"; }}</script><h1>How to install the software</h1><nav><buttononclick="readerview('novice')">view novice text</button><buttononclick="readerview('expert')">view expert text</button></nav><p>Thanks for installing AwesomeProject! With AwesomeProject,you can manage your music collection like a wizard.</p><p>But first, we need to install it:</p><pclass="expert reader">You can install AwesomeProject fromsource. Download the tar file, extract it, then run<code>./configure ; make ; make install</code></p><pclass="novice reader">AwesomeProject is available inmost Linux distributions. Check your graphical packagemanager and search for AwesomeProject to install it.</p></body></html>
1.
有了这些设置,用户可以在网页上选择他们想看的文本。
Image of window that allows you to select between novice and expert text.