html – Run a Javascript command into a iframe-ThrowExceptions

Exception or error:

i have a HTML page that include in a iframe another page, like this:

<!DOCTYPE html>
        function reload(){setTimeout(function(){document.body.firstElementChild.src+="",reload()},300000)}reload();
<iframe id="mappa" src="*********"></iframe>

Now i want to run a command into in this iframe, like this: $(".SimpleSliderDecrementButton").trigger("click");

How can i made this command running into the iframe?

How to solve:

You can try to use emit. $(youriframe).emit(‘click’), or dispatchEvent(‘click’). Also you can check the specs about emiting events.


You can use iframe.contentDocument to get access to .SimpleSliderDecrementButton inside iframe and .click() instead of .trigger().

const iframe = document.querySelector("iframe");

Leave a Reply

Your email address will not be published. Required fields are marked *