简体   繁体   English

我如何在网页上单击与我当前使用 javascript (Tampermonkey) 打开的按钮不同的按钮

[英]How do i click a button on a webpage different from the one i currently have open using javascript (Tampermonkey)

this is my first time here, so hi to everyone!这是我第一次来这里,所以大家好!

i recently started learning and practicing javascript, mostly writing scripts in Tampermonkey.我最近开始学习和练习 javascript,主要是用 Tampermonkey 编写脚本。

At one point i came across XmlHttpRequest and managed to retrieve a page in DOMstring and parse it to a DOM Tree, using the GET method.有一次,我遇到了 XmlHttpRequest 并设法在 DOMstring 中检索页面并将其解析为 DOM 树,使用 GET 方法。

Now i wonder if there's a way with XmlHttpRequest or any other way to interact with a page different than the one i currently have loaded.现在我想知道是否有一种方法可以使用 XmlHttpRequest 或任何其他方式与与我当前加载的页面不同的页面进行交互。

So for example, i have 2 pages from the same domain and the pages are a part of a CMS.例如,我有来自同一个域的 2 个页面,这些页面是 CMS 的一部分。 The first is a blank page with only a button included, the second page includes tools to review a new user account.第一个是只包含一个按钮的空白页面,第二个页面包含查看新用户帐户的工具。

Is it possible to press the button in the blank page and make an interaction in the second.是否可以在空白页面中按下按钮并在第二次进行交互。 like, pressing an "approve user account" button?例如,按下“批准用户帐户”按钮?

I should add that i cannot change things server-side and the button is created for example, with Tampermonkey.我应该补充一点,我无法更改服务器端的内容,并且例如使用 Tampermonkey 创建按钮。

Thank you for any answer i receive and i hope i wasn't too vague with my question感谢您对我的任何回答,我希望我的问题不会太含糊

It' not possible to interact with a page via XmlHttpRequest.无法通过 XmlHttpRequest 与页面交互。 What you can do, is to look, what happens, if you click the button.你可以做的是看看,如果你点击按钮,会发生什么。 If something like an GET- or POST-request is started, you could directly call that request instead.如果启动了 GET 或 POST 请求之类的东西,您可以直接调用该请求。 An interaction between two sites is also possible if you load the page in an iframe, but it might be easier to run Tampermonkey on both pages and communicate between them with GM.setValue and GM.getValue.如果您在 iframe 中加载页面,则两个站点之间的交互也是可能的,但在两个页面上运行 Tampermonkey 并在它们之间使用 GM.setValue 和 GM.getValue 进行通信可能会更容易。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Tampermonkey中打开带有网页的JavaScript窗口? - How can I open a javascript Window with a webpage in Tampermonkey? 使用油脂/篡改猴子,如何在Thesaurus.com打开Dictionary.com上当前查看的定义? - Using grease/tampermonkey, how can I have the currently viewed definition at Dictionary.com open at Thesaurus.com? 如何从 JavaScript 中单击此按钮? - How do I click this button from JavaScript? 我如何使 Tampermonkey 脚本在网站上“单击”按钮? 我试过以前在这里问过的问题 - How do i make tampermonkey script will 'click' button on website? I tried question asked here previously 如何使用 tampermonkey 在网页上加载外部脚本? - How can i load an external script on a webpage using tampermonkey? 如何使用 javascript 在另一个网页上使用 document.getElementById() 显示用户输入? - How do I display user input using document.getElementById() from one webpage on another using javascript? 当我单击我用tampermonkey添加到它的按钮时,如何阻止gmail打开email? - How to stop gmail from opening the email when I click the button I added to it with tampermonkey? 如何使用JavaScript在网页上单击一个按钮? - How does one click a button on a webpage using Javascript? 您如何使用javascript查找并单击网页上的特定按钮? - How do you find and click on a specific button on a webpage using javascript? 如何使用 javascript 在新标签页中打开网页并单击鼠标中键 - How can I open webpage in new tab with javascript and middle click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM