Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to check if 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();"> 
Comment

PREVIOUS NEXT
Code Example
Javascript :: checkbox is checked jquery 
Javascript :: jqery remove empty elment p 
Javascript :: vue router push 
Javascript :: how map on object in javascrtipt 
Javascript :: jquery datetimepicker format 
Javascript :: JS get number of classes in html 
Javascript :: js date locale brasil 
Javascript :: angular datepicker sending value one day less than 
Javascript :: react-native array.filter by index arrow function 
Javascript :: usestate in object 
Javascript :: js regex between two words 
Javascript :: get epoch timestamp js 
Javascript :: vue jest trigger input string 
Javascript :: how to check if a folder exists in node js 
Javascript :: SyntaxError: Cannot use import statement outside a module 
Javascript :: how to convert time to am pm in javascript 
Javascript :: regex validate double with 2 decimals 
Javascript :: chrome inspector console tips 
Javascript :: hiding header in a specific screen in react native 
Javascript :: ace get contents of editor 
Javascript :: javascript get data attribute of selected option 
Javascript :: jquery trigger 
Javascript :: js cant find element 
Javascript :: expo build 
Javascript :: convert hex to decimal javascript 
Javascript :: how to do a classname variable and string react 
Javascript :: react-native-checkbox in a loop 
Javascript :: nextjs absolute import 
Javascript :: parentelement javascript 
Javascript :: how to fix eslint error no-prototype-builtins 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =