2011-06-08 89 views
-2

可能重复:
getting data from child window从子窗口获取数据

我工作的一个项目,并遇到了问题。请查看下面的代码。

<iframe name="stus" id="stus" style="display:none;"></iframe><div id="posting"></div> 

<form name="water" id="water" method="post" autocomplete="off" action="components/com_pocketsea/assets/new/water.php" target="stus"> 
<input text="text" id="newwatermark" name="newwatermark"><input type="submit"></form> 

为water.php的代码是

<?php $tt = $_POST['newwatermark']; ?> 
    <script type="text/javascript" src="../../js2/jquery.min.js" ></script> 
    <script>  $(document).ready(function(){ $("#posting", window.parent.document).html("<?php echo $tt; ?>").fadeIn('slow'); }); </script> 

的脚本不能正常工作。 Water.php没有被加载到父项中。这适用于自定义,但不适用于joomla。 plz帮助。

+1

请不要重复自己的问题。你只会看到倒计时和失去朋友。 – hakre 2012-11-04 11:18:45

回答

0

可以使用opener方法来访问父窗口元素...

$('#myform').submit(function(){  
     opener.document.getElementById('parentWindowElem').innerHTML = document.getElementById ('childWindowElem').value;  
}); 
+0

它不工作 – 2011-06-08 12:04:14