您的位置:首页 > Web前端 > HTML

HTML高级应用

2006-11-30 09:43 253 查看
通过js遍历html对象的属性

function popUpProperties(inobj) {
op = window.open();
op.document.open('text/plain');
for (objprop in inobj) {
op.document.write(objprop + ' 的属性或方法: ' + inobj[objprop] + '\n');
}
op.document.close();
}

Table的单元格保持宽度不变
代码如下: 关键是两个属性 1)word-wrap
2)word-break
以及标签 <wbr>
他能在需要换行的时候自动变作换行操作

<TABLE border="1" width="200" style="table-layout:fixed;">
<TR>
<TD>dfad</TD>
<TD style="width:100;word-wrap:break-word">
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest</TD>
</TR>
</TABLE>

<TABLE border="1" width="200" style="table-layout:auto;">
<TR>
<TD>dfad</TD>
<TD style="width:100;word-wrap:break-word;word-break:break-all; ">
testtesttesttesttesttest<wbr>testtesttesttesttest<wbr>testtesttesttesttest</TD>
</TR>
</TABLE>

select元素的动态添加
<SCRIPT LANGUAGE="JScript">
var oOption = document.createElement("OPTION");
oOption.text="Ferrari";
oOption.value="4";
oSelect.add(oOption);
</SCRIPT>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: