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

iframe自适应高度,js弹出框并刷新父页面

2012-09-20 15:39 375 查看
1、iframe自适应页面高度

<script type="text/javascript">

function TuneHeight() {

var frm = document.getElementById("PhotoIframe");

var subWeb = document.frames ? document.frames["PhotoIframe"].document : frm.contentDocument;

if (frm != null && subWeb != null) {

frm.height = subWeb.body.scrollHeight;

}

}

<html>

<head></head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="0" width="100%" style=" border:0;">

<tr>

<td class="title">标题</td>

<td rowspan="2" valign="top" style=" width:270px; padding-left:5px; padding-right:5px;">

<iframe id="PhotoIframe" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" width="260" runat="server"></iframe>

</td>

</tr>

<tr>

<td valign="top" style=" border-top:0px; height:expression(this.parentElement.parentElement.rows[0].cells[1].clientHeight - 35);" >

<div id="info_div" runat="server">

<table cellpadding="0" cellspacing="0" class="atable">

<tr class="gay">

<td colspan="3" class="td_lbl">

<!--姓名:--><asp:Label ID="lblReserver1_Info" runat="server" Text=""></asp:Label>

<!--职务:--><asp:Label ID="lblReserver2_Info" runat="server" Text=""></asp:Label>

<!--证件名称:--><asp:Label ID="lblReserver3_Info" runat="server" Text=""></asp:Label>

<!--证件号码:--><asp:Label ID="lblReserver4_Info" runat="server" Text=""></asp:Label>

</td>

</tr>

</table>

<div id="info_btn" class="div_btn">

<asp:Button ID="btnUpdate" runat="server" Text="修 改" onclick="btnUpdate_Click" CssClass="btn" />   

<asp:Button ID="btnPrint" runat="server" Text="打 印" onclick="btnPrint_Click" CssClass="btn" />   

<asp:Button ID="btnBack" runat="server" Text="返 回" onclick="btnBack_Click" CssClass="btn" />

</div>

</div>

</td>

</tr>

</table>

</div>

</form>

</body>

<html>

后台:this.PhotoIframe.Attributes.Add("onload", "TuneHeight()");

2、以window.open()打开子窗口,关闭子窗口刷新父页面

<script language=JavaScript>

window.opener.location.href=window.opener.location.href;

</script>

3、以window.showModalDialog()打开子窗口,关闭子窗口刷新父页面

<script language=JavaScript>

window.parent.dialogArguments.document.execCommand('Refresh');

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: