I have tried using iframes as shown below but it's not working.
<script>
function myFunction() {
var x = document.getElementById("myframe");
var y = (x.contentWindow || x.contentDocument);
if (y.document)y = y.document;
//the code clicking the button
}
</script>
Is there a way I can trigger a button click on a web page running on a different domain? Any advice?
Almost all the modern browser block the Javascript execution on iframe by parent window... This is the security issue
mate, answer is no, impossible.
JS iFrame execution is mainly blocked in modern browser due to security issues
You can't access 3rd party website DOM using javascript. Almost all browsers prevents this due to security reasons. Consider internet banking sites for example, if it is possible to access the DOM of an internet banking site using iframe and javascript, it is very easy to steal the username and password.