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