JSFiddle - React, Tailwind, and code Playground

by ult_combo

HTML

<iframe id="ifr" src="http://example.com"></iframe>

JavaScript

$(function() {
    function checkifr() {
        function errHandler() {
            alert('Error. Try again later.');
        }
        var ifr = $('#ifr')[0];
        
        try {
            var d = ifr.contentWindow || ifr.contentDocument;
            if (!d) { console.log('entered if block');
                errHandler();
                return false;
            }
            
            var b = $('#ifr').contents().find('body');
            //... manipulate iframe content
            
        } catch(e) { console.log('entered catch block');
            errHandler();
        }
    }
    
    checkifr();
});