jsp页é¢å页é¢åç¶é¡µé¢çiframeä¼ å¼ï¼
1ï¼document.getElementById("ii").contentWindow å¾å°iframe对象åï¼å°±å¯ä»¥éè¿contentWindowå¾å°iframeå
å«é¡µé¢çwindow对象ï¼ç¶åå°±å¯ä»¥æ£å¸¸è®¿é®é¡µé¢å
ç´ äºï¼
2ï¼$("#ii")[0].contentWindow å¦æç¨jqueryéæ©å¨è·å¾iframeï¼éè¦å ä¸ä¸ªã0ãï¼
3ï¼$("#ii")[0].contentWindow.$("#dd").val() å¯ä»¥å¨å¾å°iframeçwindow对象åæ¥ç使ç¨jqueryéæ©å¨è¿è¡é¡µé¢æä½;
4ï¼$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa"; å¯ä»¥éè¿è¿ç§æ¹å¼åiframe页é¢ä¼ éåæ°ï¼å¨iframe页é¢window.hellobabyå°±å¯ä»¥è·åå°å¼ï¼hellobabyæ¯èªå®ä¹çåéï¼
5ï¼å¨iframe页é¢éè¿parentå¯ä»¥è·å¾ä¸»é¡µé¢çwindowï¼æ¥çå°±å¯ä»¥æ£å¸¸è®¿é®ç¶äº²é¡µé¢çå
ç´ äºï¼
6ï¼parent.$("#ii")[0].contentWindow.ff; å级iframe页é¢ä¹é´è°ç¨ï¼éè¦å
å¾å°ç¶äº²çwindowï¼ç¶åè°ç¨å级çiframeå¾å°windowè¿è¡æä½ï¼
å®ä¾ä»£ç ï¼
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>æ¾ç¤ºå¾è¡¨</title>
<script src="/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var gg="dsafdsafdsafdsafsdaf";
function ggMM() {
alert("22");
}
function callIframeMethod() {
//document.getElementById("ii").contentWindow.test();
$("#ii")[0].contentWindow.test(); //ç¨jqueryè°ç¨éè¦å ä¸ä¸ª[0]
}
function callIframeField() {
alert($("#ii")[0].contentWindow.ff);
}
function callIframeHtml() {
alert($("#ii")[0].contentWindow.$("#dd").val());
//alert($("#ii")[0].contentWindow.document.getElementById("dd").value);
//alert($("#ii")[0].contentWindow.document.getElementById("dd").value);
}
function giveParameter() {
$("#ii")[0].contentWindow.hellobaby="dsafdsafsdafsdafsdafsdafsadfsadfsdafsadfdsaffdsaaaaaaaaaaaaa";
}
</script>
</head>
<body>
<a href="#" onClick="giveParameter();">åæ°ä¼ é</a>
<a href="#" onClick="callIframeMethod();">è°ç¨åiframeæ¹æ³</a>
<a href="#" onClick="callIframeField();">è°ç¨åiframeåé</a>
<a href="#" onClick="callIframeHtml();">è°ç¨åiframeç»ä»¶</a></br>
<iframe id="ii" src="frame.htm" width="100%" frameborder="0"></iframe>
<iframe id="new" src="newFrame.htm" width="100%" frameborder="0"></iframe>
</body>
</html>