在做項目時
父頁面parent
<html xmlns="
<head><title>
</title>
<script src="jquery
<script type="text/javascript">
function ParentFunction() {
alert(
}
</script></head>
<body>
<input type="button" id="btnCancel" class="button" value="測試" />
<iframe id="FRMdetail" name="FRMdetail" frameborder="
</body>
</html>
子頁面child
<html xmlns="
<head><title>
</title>
<script src="jquery
<script type="text/javascript">
$(document)
$("#btnTest")
var t=window
t
});
})
</script></head>
<body>
<input type="button" id="btnTest" class="button" value="應該獲取的值" />rrr
</body>
</html>
網絡上流行的方法 var t=window
Blocked a frame with origin "null" from accessing a frame with origin "null"
網上找了很長時間都沒法發現方法
其實還有一種html
父頁面parent
<html xmlns="
<head><title>
</title>
<script src="jquery
<script type="text/javascript">
this
alert(
}
// function ParentFunction() {
// alert(
// }
function receiveMessage(e) {
var data = e
if(data=="ParentFunction")
{
ParentFunction() ;
}
}
if (typeof window
window
} else if (typeof window
window
}
</script></head>
<body>
<input type="button" id="btnCancel" class="button" value="測試" />
<iframe id="FRMdetail" name="FRMdetail" frameborder="
</body>
</html>
子頁面child
<html xmlns="
<head><title>
</title>
<script src="jquery
<script type="text/javascript">
$(document)
$("#btnTest")
var t=window
if(!t
{
t
}
else
{
t
}
});
})
</script></head>
<body>
<input type="button" id="btnTest" class="button" value="應該獲取的值" />rrr
</body>
</html>
經過改寫後
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19998.html