给网页正文提供,小 中 大 三种字体的切换功能。
用js代码设置div style的fontSize属性。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<htmL>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<style>
#content {font-size:12px;
line-height:200%;
padding:10px;
}
</style>
<script language="javascript">
function setfont(size)
{
var obj;
obj=document.getElementById("content");
obj.style.fontSize=size;
//obj.style.color="#ff0000";
}
</script>
<body>
<div>字体: <a href="#" οnclick="javascript:setfont('12px')">小</a><a href="#" οnclick="javascript:setfont('18px');">中</a><a href="#" οnclick="javascript:setfont('24px');">大</a></div>
<div id="content">
这是一段测试文字
</div>
</body>
</htmL>