ChildAppend 在新窗口中

发布于 2024-12-25 19:51:41 字数 308 浏览 2 评论 0原文

我有两个窗口,一个用于输入,一个用于显示。我希望显示窗口根据输入动态更新。我在网上找到了一个与我正在做的事情接近的示例 这里< /a> 我添加项目的位置(在示例的案例行中)。但我需要它们在其他页面而不是输入页面上更新。希望这是有道理的。

我很难在其他地方找到解决方案,但本质上我只需要附加显示表即可添加输入表中的数据。感谢您的帮助。

I have two windows, one for input and one for display. I want the display window to dynamically update according to the input. I found an example online that is close to what I am doing here where I add items (in the example's case rows). But I need them to update on the other page instead of on the input page. Hopefully that made sense.

I'm having a hard time finding solutions elsewhere but essentially I just need the display sheet to be appended to add the data from the input sheet. Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2025-01-01 19:51:41

您需要跨窗口进行通信,因此目标或目标窗口应该公开一个接收数据并将其插入文档的函数。您可以在目标窗口的全局作用域中声明一个新函数:

window.addData = function(data) {
  // Append to HTML document
}

从源窗口您必须获取对目标窗口的引用,例如通过打开它:

// Open child window and call global function of child window
var destination = window.open("destination.html", "destination");
destination.addData(42);

让这变得棘手的是您必须等待目标窗口被加载。

如果您打开的窗口应该与原始(打开的)窗口对话,您可以在子窗口中使用以下代码:

// Call global function of parent window
var destination = window.opener;
destination.addData(42);

You need to communicate across windows, so the target or destination window should expose a function that receives data and inserts it into the document. You can declare a new function in the global scope of the destination window:

window.addData = function(data) {
  // Append to HTML document
}

From the source window you must get a reference to the destination window, for example by opening it:

// Open child window and call global function of child window
var destination = window.open("destination.html", "destination");
destination.addData(42);

What makes this tricky is that you have to wait for the destination window to be loaded.

If the window you have opened should talk to the original (opening) window, you can use this code inside the child window:

// Call global function of parent window
var destination = window.opener;
destination.addData(42);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文