[英]How do you write Javascript to open page and then click on button on page in one go
I would like to open a particular webpage and then click on a button to open another page from that page.我想打开一个特定的网页,然后单击一个按钮从该页面打开另一个页面。 Now I can see how to write Javascript to find a button on page and click on it, what I dont quite understand how I can do that from the 1st page.
现在我可以看到如何编写 Javascript 来在页面上找到一个按钮并单击它,我不太明白如何从第一页开始。
ie on Page 1 can open Page 2, but how do I in one go from page 1 get it to click on a button on page 2 once page 2 is loaded because until Page 2 is loaded the button is not available, and if I just go to Page 2 my Javascript will not be running because that was on Page 1?即在第 1 页上可以打开第 2 页,但是我如何在第 1 页的一个 go 中让它在第 2 页加载后单击第 2 页上的按钮,因为在加载第 2 页之前按钮不可用,如果我只是go 到第 2 页 我的 Javascript 不会运行,因为它在第 1 页?
What I am trying to do is a poweruser feature that makes it easier to do a particular repetitive task, I am the sys adminstator for page 1 but not page 2.我想做的是一个 poweruser 功能,它可以更轻松地执行特定的重复性任务,我是第 1 页而非第 2 页的系统管理员。
This is example of the page Im trying to do this for这是我尝试为此执行此操作的页面示例
https://acoustid.org/track/61c9656b-6838-4660-8113-86f7f90fd549 https://acoustid.org/track/61c9656b-6838-4660-8113-86f7f90fd549
You need to login to Acoustid to actually see the Disable buttons您需要登录 Acoustid 才能真正看到禁用按钮
Open new browser window with js (modal or tab)用js打开新浏览器window(模态或tab)
var newWindow = window.open("http://www.....com");
Add onload handler for new window and insert script (optionally)为新的 window 添加 onload 处理程序并插入脚本(可选)
newWindow.addEventListener("DOMContentLoaded", Func);
function Func()
{
var script = newWindow.document.createElement("script");
script.text = "alert('hello');";
newWindow.document.body.appendChild(script);
}
Insert js code straightforwardly if you don't need to handle load不需要处理load的直接插入js代码
Func();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.