JQuery - 写入开启器窗口 [英] JQuery - Write to opener window

查看:76
本文介绍了JQuery - 写入开启器窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,通过JavaScript打开另一个页面。当用户单击其他页面中的按钮时,我想通过JQuery在开始页面的DIV中发布消息。我不能把它放在手上,但我似乎无法得到这个工作。这是我的首页页面

 < html> 
< head>
< script type =text / javascriptsrc =jquery-1.3.2.min.js>< / script>
< / head>

< body>
< input type =buttononclick =window.open('dialog.html','_blank','height = 200,width = 300');值=发射! />
< div id =testDiv>< / div>
< / body>
< / html>

当用户点击发射!时按钮,会出现一个对话框。该对话框的代码如下所示:

 < html> 
< head>
< script type =text / javascriptsrc =jquery-1.3.2.min.js>< / script>
< / head>

< body>
< input type =buttononclick =updateOpener()value =Update Opener/>
< script type =text / javascript>
function updateOpener()
{
var testDiv = window.opener.jQuery(#testDiv);
if(testDiv!= null){
alert(here);
testDiv.html(已更新!);
}
}
< / script>
< / body>
< / html>

令人惊讶的是,出现了警告框。但是,我似乎无法在我的开始页面更新DIV的HTML。有人知道如何做到这一点吗? 你引用了confirmDiv。那个DIV在哪里?


I have an HTML page that opens another page via JavaScript. When a user clicks a button in the other page, I want to post a message in a DIV of the opening page via JQuery. I cannot put my finger on it, but I cannot seem to get this to work. Here is my opener page

<html>
  <head>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
  </head>

  <body>
    <input type="button" onclick="window.open('dialog.html', '_blank', 'height=200, width=300');" value="launch!" />
    <div id="testDiv"></div>
  </body>
</html>

When the user clicks the "launch!" button, a dialog will appear. The code for the dialog looks like this:

<html>
  <head>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
  </head>

  <body>
    <input type="button" onclick="updateOpener()" value="Update Opener" />
    <script type="text/javascript">
      function updateOpener()
      {
        var testDiv = window.opener.jQuery("#testDiv");
        if (testDiv != null) {
      alert("here");
      testDiv.html("Updated!");
        }
      }
    </script>
  </body>
</html>

Surprisingly, the alert box appears. However, I cannot seem to update the HTML of the DIV in my opening page. Does anyone know how to do this?

解决方案

You're referencing "confirmDiv". Where is that DIV?

这篇关于JQuery - 写入开启器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆