Ifram中父頁面呼叫子頁面的實現方法
frame1中呼叫 frame2中的方法 js自己去網上載一個吧
實現方式1:
頁面1程式碼
<html>
<head>
<script src="jquery-1.8.2.min.js"></script>
</head>
<body id='fa'>
<iframe src='iframe2.html' width='100' height='100'></iframe>
<br>
<br>
<br>
<div id='mydiv'>content iframe</div>
</body>
<script>
function a() {
alert(1);
}
alert($(document).text());
</script>
</html>
頁面2程式碼
<html>
<head>
<script src="jquery-1.8.2.min.js"></script>
</head>
<body id='1'>
<div>it is a iframe</div>
</body>
<script>
$(document).ready(
function(){
var c = $(window.parent.document.body)
//麻煩的方法: var c = $($(window).eq(0)[0].parent.document).find('body'); ,忘了可以用前面的方法了
alert(c.html());
}
);
</script>
</html>
實現方式2:$("#ueditor_0").contents().find("#special").css("font-size","16px");
//說明:ueditor_0 為iframe的id , special 為子頁面元素