<html>
<head>
<style type="text/css">
</style>
<META http-equiv="content-type" content="text/html; charset=shift_jis">
<title>TEST</title>
</head>
<LINK rel="stylesheet" href="../css/table.css" type="text/css" id="_HPB_TABLE_CSS_ID_">
<script type="text/javascript">
function SC(){
document.FMlog.txt1.value
document.getElementById("p1").innerHTML = document.FMlog.txt1.value;
//alert(document.FMlog.txt1.value);
alert(document.getElementById("p1").offsetWidth);
}
</script>
</head>
<body bgcolor= "#ffffff">
<form method="post" action="" name="FMlog">
<input name="txt1" type="text" />
<input name="btn1" type="button" onclick="SC()" value="click me"/>
<span id="p1" style="visibility:hidden"></span>
</form>
</body>
</html>
<head>
<style type="text/css">
</style>
<META http-equiv="content-type" content="text/html; charset=shift_jis">
<title>TEST</title>
</head>
<LINK rel="stylesheet" href="../css/table.css" type="text/css" id="_HPB_TABLE_CSS_ID_">
<script type="text/javascript">
function SC(){
document.FMlog.txt1.value
document.getElementById("p1").innerHTML = document.FMlog.txt1.value;
//alert(document.FMlog.txt1.value);
alert(document.getElementById("p1").offsetWidth);
}
</script>
</head>
<body bgcolor= "#ffffff">
<form method="post" action="" name="FMlog">
<input name="txt1" type="text" />
<input name="btn1" type="button" onclick="SC()" value="click me"/>
<span id="p1" style="visibility:hidden"></span>
</form>
</body>
</html>
解决方案 »
- javascript可以让asp的dropdownlist的项隐藏吗?enabled和visible好像都不管用
- 弹出菜单的问题~~
- Ext中Combox的诡异问题
- 动态事件
- 请问这是什么语法?
- DIV层IE兼容性问题,外层的DIV控件的onBlur事件,在触发内层的时候,如何解决冒泡问题
- 高难问题,动态添加对象(本人认为)
- 在一个页面中如何传递变量的值?
- 一个有关window.open的小问题(初学者)。谢谢大家指教
- 关于改变iframe的问题?
- 请教高人写个函数:javascript中 把\r\n替换成<br>空格替换成 还有相反的转换函数如何写?谢谢
- 请问怎么样实现右击全选的功能?
function sumStr(str)
{var num=str.length;
var arr=str.match(/[^\x00-\x80]/ig);
if(arr!=null)
num+=arr.length;
return num;
}
sumStr("aavb 你好 啊!")
另外 如果你只是不想文本超过TD的宽度 大可以加个<div>标签
例如:
<td width="160">
<div style="overflow-x:hidden;width='100%'">你要的内容</div>
</td>
这样你的TD内容一旦超过显示范围就会被隐藏.
如果你还想看到其中的内容的话可以这样写
<td width="160" valign="top" align="left">
<div style="overflow-x:hidden;width='100%'" onmouseover="this.style.position='absolute';this.style.overflowX=''" onmouseout="this.style.position='';this.style.overflowX='hidden'">
</td>
<td width="160" valign="top" align="left">
<div style="overflow-x:hidden;width='160'" onmouseover="this.style.position='absolute';this.style.overflowX=''" onmouseout="this.style.position='';this.style.overflowX='hidden'"></div>
</td>
这样你的鼠标一移到文字上面 就会显示出之前没显示出来的内容
鼠标一移开就会自动隐藏注如果用这个的话 可能 要稍微调下表格单元的高度
<tr>
<td width="160">
<div style="overflow-x: hidden;width: 100%;">你要的内容你要的内容你要的内容你要的内容</div>
</td>
</tr>
</table>
超过宽度时还是一无反顾地换了行,没有隐藏呀!?
<tr>
<td width="160">
<div style="overflow-x: hidden;width: 160px;">你要的内容你要的内容你要的内容你要的内容</div>
</td>
</tr>
</table>
兄弟是这样吗?不行哦:(
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="160"><div style="overflow-x:hidden;width:160px">fasfsdaasdfasdfasdffsadfsasdfsadfasdfadfasdfsdfsdfasdf</div></td>
<td width="160"> </td>
</tr>
</table>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="160"> <div style="overflow-x:hidden;width:160px">fasfsdaasdfasdfasdffsadfsasdfsadfasdfadfasdfsdfsdfasdf</div> </td>
</tr>
</table>
这样写
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#999999">
<tr>
<td width="160">
<div nowrap style="overflow: hidden;width: 160px;">你要的内容你要的内容你要的内容你要的内容</div>
</td>
</tr>
</table>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td nowrap><div style="overflow-x:hidden;width:160px" onmouseover="this.style.position='';this.style.overflowX=''" onmouseout="this.style.position='';this.style.overflowX='hidden'">你要的内容你要的内容你要的内容你要的内容</div></td>
<td width="160"> </td>
</tr>
</table>
要这样写,因为TD元素noWrap属性的行为与TD元素的width属性有关。◆如果未设置TD宽度,则noWrap属性是起作用的。
◆如果设置了TD宽度,则noWrap属性是不起作用的。
用div控制160像素,用td控制不能自由换行
而我加noWrap的元素是DIV所以不会产生此类问题