前端小技巧

td中的内容自动换行:

<td width="1000" style="vertical-align: top;word-wrap: break-word;word-break: break-all;"></td>

固定div的显示位置、设定大小(X轴、Y轴都有滚动条):

<div style="width: 100%;height: 500px;overflow: scroll;position:absolute; left: 1px;top: 70px;">

fieldset标签:

<fieldset>    
    <legend>health information</legend>     
    height: <input type="text" />     
    weight: <input type="text" />
</fieldset>

返回上页:
(1)window.location.href=’’;
(2)window.history.go(返回第几页,也可以使用访问过的URL);[说明:-1表示上一页;-0表示刷新;-2表示上两页]
(3)window.history.back();

刷新页面:
(1)window.location.reload(); [刷新本页面]
(2)opener.location.reload(); [刷新父页面]
(3)self.opener.location.reload(); [子窗口刷新父窗口]
(4)parent.另一FrameID.location.reload(); [刷新另一个框架的页面]
(5) [打开窗口时刷新]
(6) [关闭窗口时刷新]

打开新窗口:

window.open (''page.html'',''newwindow'',''height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no'');

去掉超链接激活时的边框线:
(1)如果,要是这样去修改网站中所有的链接来实现该效果,肯定是不现实的。要通过在CSS的链接属性里加一条语句,可以做到批量修改:

a{
    blr:expression(this.onFocus=this.blur());
}

注:这个好像只有IE才有效果,FireFox中还是有边框虚线出现。

(2)CSS样式:

<style type="text/css">
    .hideFocus{hide-focus: expression(this.hideFocus=true);} 
</style>

冻结行(不合并行的情况下有用):

style="background-color: #ababab;position: relative;top: expression(this.offsetParent.scrollTop);"

showModalDialog:

window.showModalDialog(sUrl, "ypbh:"+ypbh+"", status=no;dialogWidth=1105px;dialogHeight=500px;menu=yes;resizeable=no;scroll=yes;center=yes;edge=raise");

子窗口给父窗口赋值:
老写法:

window.parent.document.getElementById("cInvName").value = str;

jQuery 的写法:

$("#cInvName", window.parent.document).val(str);

添加代码:
老写法:

window.parent.document.getElementById("divObj").innerHTML="hello 114look.com";

jQuery写法:

$("#divObj", window.parent.document).html("hello 114look.com"); 

window.open.$("#divObj").val("0123");

获取iframe中的document对象:

$(window.frames["iframe"].document).find("input[name='abc']").val()

获得iframe中的iframe对象:

$(window.frames["iframe1"].frames["iframe2"].document).find("input:radio").attr("checked","true");
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值