怎样获取文本框中文本的宽度,像素值?

1<script language="javascript">   
2function test(obj)   
3{   
4var range = obj.createTextRange();   
5alert("内容区宽度: " + range.boundingWidth   
6\+ "px\r\n内容区高度: " + range.boundingHeight + "px");   
7  
8}   
9</script>
1<body>
2<input id="txt"/><input onclick="test(txt)" type="button" value="计算内容宽度"/>
3</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus