用javascript按外部网站上的按钮 [英] press a button on external site with javascript
问题描述
有没有办法用javascript和/或jquery按下外部网站上的按钮?就像我打开一个这样的新窗口:
is there a way to press a button on external site with javascript and/or jquery? Like I open a new window like this:
windowObjectReference = window.open("http://some_site.html","name");
然后我想按下此网站上的按钮。这样的事情:
Then I want to press a button on this site. Something like this:
windowObjectReference.button.click();
或者:
name.button.click();
推荐答案
如果浏览器会出现严重的安全违规行为让你从你自己网站上的脚本中做到这一点。
It would be a huge security violation if a browser would let you do that from the script placed on your own website.
所以,不,这不可能完成,而且不可能。
但是......
如果两个网站都属于您(您可以访问他们的代码),那么可以传递参数(例如,作为URL中的哈希),然后目标网站可以读取它并触发您提到的事件( name.button.click()
)。
If both sites belong to you (you have access to their code), you can pass a parameter (eg. as a hash within URL), then the target website may read it and fire the event you mentioned (name.button.click()
).
这篇关于用javascript按外部网站上的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!