JQuery iframeページ親ページの要素とメソッドの操作
2022 ワード
<%@ Page Language="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="IframeDemo._Default"%>
$("id").window.functionName();
window.parent.goNext();//サブページコール付ページ関数
$("#svgEle").contents().find("#blackLine").attr('stroke',color); 親ページアクションサブページ
$("#mainframe",parent.document.body).attr("src","http://www.baidu.com")サブページ呼び出し親ページ var hello = 'hello';
function getHelloWorld() {
alert('hello world');
}
<%@ Page Language="C#"AutoEventWireup="true"CodeBehind="IFrame.aspx.cs"Inherits="IframeDemo.IFrame"%>
$(function() {
//iframeで親ページ要素を検索する
alert($('#default', window.parent.document).html());
//iframeで親ページで定義したメソッドを呼び出す
parent.getHelloWorld();
//iframeで親ページで定義した変数を呼び出す
alert(parent.hello);
});