学习笔记之Iframe
1. iframe的用法
在aspx的<form></form>之間加入如下代碼:
<IFRAME id="ifrm" height="100%" width="100%" frameBorder="no" scrolling="no" runat="server">
</IFRAME>
動態調用:
在cs的聲明部分加入iframe的聲明:
protected System.Web.UI.HtmlControls.HtmlGenericControl ifrm;
引用為
ifrm.Attributes["src"]="http://www.google.com";
2. 讓iframe的height自動調整以適應里面的內容,不出現滾動條。
在父頁面中
<div id="div1"><iframe name=...? src=... style="Z-INDEX: 2; VISIBILITY: inherit; WIDTH: 100%; HEIGHT: 100%" frameborder="0" scrolling="no"></iframe></div>
????
iframe中頁面:
function window.onload()
{
? var div = window.parent.document.getElementById('div1');
? div.style.height=document.body.scrollHeight+20;
}
3. 通過點擊iframe中datagrid中的ImageButton,得到datagrid第一列的值,將這值傳回父頁。
foreach(DataGridItem CurRow in DataGrid1.Items)
{
((ImageButton)CurRow.Cells[2].Control[1]).Add("onclick","return(setValue("+((Label)CurRow.Cells[1].Control[1]).Text+"'));");
}
在aspx中加入
<script>
function setValue(txt)
{
??? window.parent.iframe名.all.textarea名.innerText=txt;
??? return false;
}
</script>
4. 主頁中一個treevie 點擊節點以后 iframe 調用子頁也是內容,子頁進行修改以后點確定按鈕刷新主頁的treeview如何做。
子頁
void Page_Load(Object sender, EventArgs e)
{
? YourButton.Attributes["onclick"] = "javascript:parent.document.forms[0].submit(); return false;";
}
5. 頁面A.ASPX中嵌入了一個iframe,iframe的href指向B.ASPX,在B中有一個button,如何才能讓點擊這個button來刷新A.ASPX呢?
parent.window.location.reload("框架的url");
6. 有一個home.aspx的頁面,里面有兩個iframe名字分別為A和B,我現在想在A的iframe頁面里寫一個跳轉語句,可以讓整個home頁面都跳轉而不是只是在A里面跳轉,用this.Response.Redirect只是在A里面跳轉.
Response.Write("<script language=javascript>window.parent.location.href='url'</script>")
轉載于:https://www.cnblogs.com/jadychu/archive/2006/04/20/380384.html
總結
以上是生活随笔為你收集整理的学习笔记之Iframe的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Castle ActiveRecord学
- 下一篇: oracle基本概念和术语