1 时间的截取
try{
var addtime = document.getElementsByName("addtime");
for(var i=0;i<addtime.length;i++){
var strs = addtime[i].innerText
if(strs.length >10){
addtime[i].innerText =strs.substring(0,19);
}
}
}catch(e){
}
<label id="addtime" name="addtime">${merchant.successDate }</label>
2 页面内容的截取 内容过多可以用省略号来表示
<style>
.ellipsis_div{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
wzy:expression(void(this.title=this.innerText));
}
</style>
<div class=ellipsis_div
style="width:120px;background-color:#cc88ff;">somelongtextsomelongtext</div>
<div class=ellipsis_div
style="width:110px;background-color:#dddddd;">some long text</div>
3 下拉框只选中一个
<script language="javascript">
function tobox(obj){
var boxid = document.getElementById("id");
var boxes = document.getElementsByName("box");
for (var i = 0; i < boxes.length; i++){
if (boxes[i]==obj){
boxid.value = obj.value;
obj.checked;
}else{
boxes[i].checked='';
}
}
}
</script>
<body>
<input type="checkbox" id="box" name="box" value="οnclick="tobox(this)" />
<input type="hidden" name="id" id="id" />
</body>
4子窗口跳出
<a href="javascript:{window.top.location.href='<%=path%>/merchant/premissions.do?task=get&trueName=${staff.userName }'}" >权限设置</a>
5 获得iframe中表单的值
var ss=document.frames["iframe的id"].listuser.id.value;listuser为表单名 id为表单属性
6 刷新iframe的src
document.getElementById("reportmanage").src=str
reportmanage是iframe的id