[英]Post a data to iframe(aspx) to capture it in Page load of aspx page
[英]How to resize an IFRAME on load in an .aspx page?
在帶有VB.NET代碼的.aspx頁中,我使用的是IFRAME,該IFRAME將在轉發器控件內創建。
由於我想根據頁面內的內容調整IFRAME的大小,因此我一直在使用IFRAME onload 從此處獲得的調整大小功能,如下所示。
<iframe id="IframeSubsectionArea" scrolling="auto" width="100%" onload="resizeIframeToFitContent(this)" runat="server">
但是,由於在表單中找不到該方法,因此拋出了錯誤。
如果您不介意使用jQuery,則這里的第一個答案應該是在動態插入的iframe中實現jQuery .ready的技巧
$(document).ready(function() {
$("iframe").load(function() {
var iframe = $(this);
//Do your resize here via the iframe var
});
});
失敗的話,由於此代碼塊從您的文檔中丟失,您可能會收到錯誤,但是由於您尚未發布實際錯誤,因此我無法確定。
<SCRIPT LANGUAGE="JavaScript">
function resizeIframeToFitContent(iframe) {
// This function resizes an IFrame object
// to fit its content.
// The IFrame tag must have a unique ID attribute.
iframe.height = document.frames[iframe.id]
.document.body.scrollHeight;
}
</SCRIPT>
編輯:如果不起作用,請發布一些示例代碼,以及您得到的實際錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.