下面的代码:点击缩小字体和增加字体时提示无效对象啊<html>
<head>
<title>
动态修改页面上的文字的字体
</title>
<script language="javascript">
    var newasp_fontsize = 9;
    var newasp_lineheight = 18;
//增加字体
addfontsize1 = function()
{
    document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + &quot;pt&quot;
   document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight +&quot;pt&quot;
}
//缩小字体
decfontsize2 = function() {
    document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + &quot;pt&quot;
    document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + &quot;pt&quot;
}
</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>

解决方案 »

  1.   

     function addfontsize1()
    {
        document.getElementById("NewaspContentLabel").style.fontSize = ++newasp_fontsize + &quot;pt&quot;
      document.getElementById("NewaspContentLabel").style.lineHeight = ++newasp_lineheight +&quot;pt&quot;
    }
    //缩小字体
     function  decfontsize2 () {
        document.getElementById("NewaspContentLabel").style.fontSize = --newasp_fontsize + &quot;pt&quot;
        document.getElementById("NewaspContentLabel").style.lineHeight = --newasp_lineheight + &quot;pt&quot;
    }
      

  2.   

    + &quot;pt&quot; 
    这里是什么
    应该是   ;
      

  3.   

    谢谢!<script language="javascript" type="text/javascript">
        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>
    这样可以了
      

  4.   

    我试了你的代码,没有报错啊,能正常调整,不过因为你的文字包含在一个<font>中,而你改变的是外层div的字体,所以效果是字体没有改变,但是两个段落间的距离在改变
    <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()
      

  5.   

     <html>
    <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>
    测试没得错误了
      

  6.   

    用 pt 也可以啊,只是要把 &quot; 换成双引号