0
我有一個問題,我的iframe發送一個變量,它的父功能。 topPHP.php是我的父母,它具有導致我問題的功能和加載entryPHP.php的iframe,這是一種將pdf文檔的帖子發送到loadPHP.php的表單,該表單將pdf上傳到我的數據庫並調用函數父級的topPHP.php。對運行的句子感到抱歉。我得到的結果如下:Jquery Iframe調用頂部或父函數
when topPHP.php loads the div topDiv reads "No Control"
I choose a file in the iframe (src = entryPHP.php) and hit submit
loadPHP.php is called and the file is upload to the database perfectly
In the Javascript/Jquery the alert "before the function" is called and works
After that the div topDiv still reads "No Control" and the second alert "after the function" is not called
任何幫助將不勝感激。
topPHP:
<script type="text/javascript" src="../jQuery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
num = 1;
function changeDiv(num){
if(num==1)
{
$("#topDiv").val("top control");
}
if(num==2)
{
$("#topDiv").val("bottom control");
}
}
}
</script>
<iframe id="iframe_display" src="entryPHP.php" width="400" height="100">
</iframe>
<div id="topDiv">
no control
</div>
entryPHP:
<div id="uploadPDF">
<form enctype="multipart/form-data" method="POST" action="loadPHP.php">
<table width="300" height="25" border="1">
//this table sends a pdf file as a post to loadPHP.psh
</table>
</form>
loadPHP:
<?php
//this uploads the pdf file to the database
?>
<script type="text/javascript" src="../jQuery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(window).load(function(){
});
alert("before the function");
parent.changeDiv(2);
alert("after the function");
});
</script>
感謝
謝謝您的答覆。我已經嘗試過,並得到相同的結果。此外,我已經嘗試使用top.topDiv和window.parent.topDiv,並沒有什麼似乎爲我工作。另外window.changeDiv = function(num)。 – user908759 2013-03-25 17:17:01
nm使它適用於您的設置。我有一個函數在window.load(),這是導致一些問題......謝謝 – user908759 2013-03-25 19:56:47