如何使JavaScript脚本在页面中运行不止一次
我的网站有按钮A。当我单击它时,出现一个弹出式div,是否选项。我必须单击是。因此,我写了一个脚本,以便当我单击按钮A时,是自动单击的“是”选项。就像这样,
buttonA.onclick = function(){
document.getElementById('buttonYes').click()
};
我将其加载到Tampermonkey中。当页面加载时,代码首次工作。之后,按钮回到了他们的原始行为。 JavaScript某人仅在新加载页面时仅能工作一次。有人可以提出一种使代码一直在页面中工作的方法,我不需要重新加载页面才能工作。
My website has button A. When I click it a pop up div appears with yes no option. I must click yes. So I write a script so that when I click button A, the yes option is automatically clicked. It goes like this
buttonA.onclick = function(){
document.getElementById('buttonYes').click()
};
I load this into Tampermonkey. When the page loads, the code work for the first time. After that the button goes back to their original behavior. The Javascript somehome only works once when the page is newly loaded. Can someone suggest a way to make the code works all the time in the page and I don't need to reload the page for it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论