Answers for "jquery access function on iframe"

1

jquery get iframe content

$("#myiframe").contents().find("#myContent")

<!-- Example : http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/-->
<!-- Doc : https://api.jquery.com/contents/ -->
Posted by: Guest on February-27-2021
0

jquery when iframe is loaded

<script>
function checkIframeLoaded() {
    // Get a handle to the iframe element
    var iframe = document.getElementById('i_frame');
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;

    // Check if loading is complete
    if (  iframeDoc.readyState  == 'complete' ) {
        //iframe.contentWindow.alert("Hello");
        iframe.contentWindow.onload = function(){
            alert("I am loaded");
        };
        // The loading is complete, call the function we want executed once the iframe is loaded
        afterLoading();
        return;
    } 

    // If we are here, it is not loaded. Set things up so we check   the status again in 100 milliseconds
    window.setTimeout(checkIframeLoaded, 100);
}

function afterLoading(){
    alert("I am here");
}
</script>

<body onload="checkIframeLoaded();">
Posted by: Guest on August-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language