Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 1.17 KB

File metadata and controls

28 lines (20 loc) · 1.17 KB

How to click programmatically button inside iframe?

There can be situations when we would like to customize iframe content or trigger some actions from outside iframe window.

Presented demos display how to make button that is outside iframe – clicking button placed inside iframe.

Example of clicking iframe button (from outside iframe):

<script>
    function triggerClickInsideIframe() {
        document.getElementById("myIframe").contentWindow.document.getElementById("toggleDivButton").click();
    }
</script>

Notice: iframe modifications are allowed only for same-origin urls (the same protocol and domain)

Demo1

Demo2

Demo3

Learn More

Learn more in the article: 'How to Trigger a Click Event Inside an Iframe?'