跨选项卡复制数据
我在两个不同的选项卡中得到了两种不同的表格。一个包含来自我们系统的数据,另一个是另一个外部系统的接口,我们需要将数据复制到其中(XML 或 API 集成不是这里的选项)。
这就是说,以两种不同的方式打开这两种形式选项卡 - 我需要一个greasemonkey脚本或类似的东西,允许我将数据从一种表单复制到另一种表单(使用Javascript中的getValue方法)。
现在的问题是,我无法弄清楚如何使用greasemonkey脚本引用一个特定的选项卡或窗口(从中读取数据或向其中写入数据)。你认为有可能做我想做的事吗?
谢谢
I got two different forms in two different tabs. One has data from our system and the other one is an interface of another, external, system in wich we need to copy data into (XML or API integration not an option here)
The this is that, having open both forms - in two different tabs - i need a greasemonkey script or something similar that allows my to copy data from one form to the other (using the getValue method in Javascript).
The problem right now is that I cannot figure out how to reference with a greasemonkey script one particular tab or window (to rad data from or write data to). Do you think it would be possible to do what I'm thinking to do?
THANKS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我相信这是可能的。 Greasemonkey 存储的配置值按脚本存储,因此您需要确保您的单个 Greasemonkey 脚本针对这两个页面运行,即使它们位于不同的 URL。 (更多信息。)
您可能需要一个大的 if/else 块来将要在源页面和目标页面上运行的代码分开,如下所示:
这似乎比在一页上执行脚本并尝试访问其他打开的窗口的 DOM 更容易(我不是当然是可能的)。
Yes, I believe it's possible. Greasemonkey stored configuration values are stored per script so you need to make sure that your single Greasemonkey script runs against both of those pages, even if they're at different URLs. (More info here.)
You're probably going to want a large if/else block to divide up the code you want to run on the source page and on the target page, with something like this:
This seems easier than having the script execute on one page and try to access the DOM of other open windows (which I'm not sure is possible).