Script for autoclick

0

I'm trying to make a script that autoclicks a part of an iframe.

The idea is this:

On my website (web 1) there will be an iframe from another website (web 2). The idea is that when you load the web1, an autoclick is made in a specific part of the iframe of web 2.

So far, the only thing I found was a code in javascript that does autoclick, but only in buttons, not in iframes.

I do not know if this will be possible to do it with a code in javascript, that of click by coordinates.

    
asked by juan186 23.12.2016 в 17:37
source

2 answers

1

If the url loaded in the iframe is from the same domain as the page from which you are running the code, you should be able to access the iframe elements through the document property of the iframe:

 window.frames['myIFrame'].document.getElementById('myIFrameElemId')

If, as you mention, the content of the iframe is from another website (I understand that from another domain), the browser's security policies will not allow you to access its content.

    
answered by 08.07.2017 в 10:24
0

You can not access the iframe and modify it unless you have the code of the page that will be in iframe and what you can do "with your code" is a specific function for what you are doing, for example when loading the page from an iframe that executes that option that you are looking for. You just have to do a validation in javascript like the following:

function inIframe () {
    try {
        return window.self !== window.top;
    } catch (e) {
        return true;
    }
}

If it returns true then it is an iframe and you can execute what you need.

    
answered by 26.12.2016 в 19:11