国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現iframe父窗體和子窗體的相互調用

2019-11-20 09:41:02
字體:
來源:轉載
供稿:網友

本文實例講述了jQuery實現iframe父窗體和子窗體的相互調用方法。分享給大家供大家參考,具體如下:

父窗體

<html>  <head>    <title>usually function</title>  </head>  <body>    <iframe src="http://www.baidu.com" ></iframe>    <iframe src="myifame.html" id="name_iframe" name="name_iframe"></iframe>    <button value="buttonvalue" id="testid">buttonvalue</button>  </body><html><script type="text/javascript" src="jquery-1.4.4.js"></script><script>//contentWindow這個屬性,相當于獲取iframe網頁里面的window對象$(function(){  //父窗體獲取子窗體的變量  alert(document.getElementById("name_iframe").contentWindow.vname);//父窗體獲取子窗體的方法  document.getElementById("name_iframe").contentWindow.test();//父窗體獲取子窗體的內容  alert(document.getElementById("name_iframe").contentWindow.document.body.outerHTML);});var myname="hb";function parentFunction(){  alert("parentFunction");}</script>

子窗體

<html>  <head>    <title>usually function</title>  </head>  <body>    <button onclick="getParentContent()">getParentContent</button>  </body><html><script type="text/javascript" src="jquery-1.4.4.js"></script><script>var vname="v_name";function test(){  alert("function test");}function getParentContent(){  //獲取父窗體的變量  alert(window.parent.myname);  //獲取父窗體的方法  window.parent.parentFunction();  //獲取父窗體的dom節點  alert(parent.document.getElementById("testid").value);}</script>

更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結》、《jquery中Ajax用法總結》、《jQuery表格(table)操作技巧匯總》、《jQuery拖拽特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結

希望本文所述對大家jQuery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大余县| 定兴县| 腾冲县| 海安县| 元江| 肥城市| 左贡县| 固始县| 沐川县| 万安县| 洛南县| 张掖市| 晋中市| 黑水县| 抚松县| 滨海县| 女性| 海口市| 西丰县| 天全县| 鞍山市| 贡嘎县| 建阳市| 民丰县| 会同县| 德钦县| 永济市| 徐闻县| 孟连| 石河子市| 句容市| 滦南县| 临夏县| 伊吾县| 巴青县| 故城县| 砀山县| 获嘉县| 普宁市| 东安县| 抚顺县|