下面的代码:点击缩小字体和增加字体时提示无效对象啊<html>
<head>
<title>
动态修改页面上的文字的字体
</title>
<script language="javascript">
var newasp_fontsize = 9;
var newasp_lineheight = 18;
//增加字体
addfontsize1 = function()
{
document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight +"pt"
}
//缩小字体
decfontsize2 = function() {
document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + "pt"
}
</script>
</head>
<body>
<table width="100%" height="100%" border=1 bordercolor=gray>
<tr>
<td height=24 colspan=2 width="100%" align=right>
<a style="CURSOR: hand; POSITION: relative" onclick="addfontsize1()" title="减小字体" id="addfont"><img src="img/dec.gif" border="0" width="15" height="15"><font color="#FF6600">减小字体</font></a>
<a style="CURSOR: hand; POSITION: relative" onclick="decfontsize2()" title="增大字体" id="decfont"><img src="img/add.gif" border="0" width="15" height="15"><font color="#FF6600">增大字体</font></a>
</td>
</tr>
<tr>
<td width="20%" >
导航栏
</td>
<td idth="80%"><div id="NewaspContentLabel" style="display:block;padding:0px 10px;LINE-HEIGHT: 18pt;"><FONT id=font_word style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"><P><font face=Verdana>浙江经贸学院周文根一行来中心参观</font></P>
<P>2009年2月27日,浙江经贸学院P>
</font></div>
</td>
</tr>
</table>
</body>
</html>
<head>
<title>
动态修改页面上的文字的字体
</title>
<script language="javascript">
var newasp_fontsize = 9;
var newasp_lineheight = 18;
//增加字体
addfontsize1 = function()
{
document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight +"pt"
}
//缩小字体
decfontsize2 = function() {
document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + "pt"
}
</script>
</head>
<body>
<table width="100%" height="100%" border=1 bordercolor=gray>
<tr>
<td height=24 colspan=2 width="100%" align=right>
<a style="CURSOR: hand; POSITION: relative" onclick="addfontsize1()" title="减小字体" id="addfont"><img src="img/dec.gif" border="0" width="15" height="15"><font color="#FF6600">减小字体</font></a>
<a style="CURSOR: hand; POSITION: relative" onclick="decfontsize2()" title="增大字体" id="decfont"><img src="img/add.gif" border="0" width="15" height="15"><font color="#FF6600">增大字体</font></a>
</td>
</tr>
<tr>
<td width="20%" >
导航栏
</td>
<td idth="80%"><div id="NewaspContentLabel" style="display:block;padding:0px 10px;LINE-HEIGHT: 18pt;"><FONT id=font_word style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"><P><font face=Verdana>浙江经贸学院周文根一行来中心参观</font></P>
<P>2009年2月27日,浙江经贸学院P>
</font></div>
</td>
</tr>
</table>
</body>
</html>
解决方案 »
- ztree不能获取焦点
- 如何检测客户端是否安装了RealPlayer
- hwkj.jquery.chromatable.js锁定表头竖线对齐问题
- showModelessDialog窗口彈出問題(help)
- 滑动门技术,第一次预览能显示内容,再点回来就不能显示了呢?
- iframe的问题(非常奇怪),在线等
- 验证输入是否是数字的函数如何写?
- 如何捕获关闭网页的事件
- ■■请教:HTML页面上的动态信息由用户维护,如增添修改一些信息,如何来写这样脚本,给个例子好吗?■■
- datepicker ie8 位置错位
- js 正则中的分支条件问题
- 请问,以下打印代码! 如何清空页头页尾的打印,调整纸边间距大小,默认为横向的打印!
{
document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight +"pt"
}
//缩小字体
function decfontsize2 () {
document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + "pt"
document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + "pt"
}
这里是什么
应该是 ;
var newasp_fontsize = 9;
var newasp_lineheight = 18;
//增加字体
addfontsize1 = function()
{
document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + "px";
document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight + "px";
}
//缩小字体
decfontsize2 = function() {
document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + "px";
document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + "px";
}
</script>
这样可以了
<FONT id=font_word style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"> <P> <font face=Verdana>浙江经贸学院周文根一行来中心参观 </font> </P>
<P>2009年2月27日,浙江经贸学院P>
</font>
另外,你的“减小字体”,调用的是 addfontsize1(),"增大字体"则用decfontsize2()
<head>
<title>
动态修改页面上的文字的字体
</title>
<script language="javascript">
var newasp_fontsize = 9;
var newasp_lineheight = 18;
//增加字体
function addfontsize1()
{
document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize ;
document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight ;
}
//缩小字体
function decfontsize2() {
document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize;
document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight;
}
</script>
</head>
<body>
<table width="100%" height="100%" border=1 bordercolor=gray>
<tr>
<td height=24 colspan=2 width="100%" align=right>
<a href="#" title="减小字体" id="addfont" onclick="addfontsize1()"> <img src="img/dec.gif" border="0" width="15" height="15"> <font color="#FF6600">减小字体 </font> </a>
<a href="#" title="增大字体" id="decfont" onclick="decfontsize2()"> <img src="img/add.gif" border="0" width="15" height="15"> <font color="#FF6600">增大字体 </font> </a>
</td>
</tr>
<tr>
<td width="20%" >
导航栏
</td>
<td idth="80%"><div id="NewaspContentLabel" style="display:block;padding:0px 10px;LINE-HEIGHT: 18pt;"> <FONT id=font_word style=" FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"> <P> <font face=Verdana>浙江经贸学院周文根一行来中心参观 </font> </P>
<P>2009年2月27日,浙江经贸学院副院长周文根、教务处处长章剑林、设备处处长梁小碗等一行15人在学校副院长冯浩,设备处处长尤小军,副处长李成和中心副主任张玉才的陪同下进行了参观和交流。 </P>
</font> </div>
</td>
</tr>
</table>
</body>
</html>
测试没得错误了