Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

run javascript in iframe

var iframe = document.getElementById('frameID'),
    iframeWin = iframe.contentWindow || iframe,
    iframeDoc = iframe.contentDocument || iframeWin.document;

window.hello = function () {
    alert('hello from owner!');
};

$(iframeDoc).ready(function (event) {
    iframeDoc.open();
    iframeDoc.write('iframe here');
    iframeDoc.write('<script>alert("hello from iframe!");</script>');
    iframeDoc.write('<script>parent.hello();</script>');
    iframeDoc.close();
});
Source by jsfiddle.net #
 
PREVIOUS NEXT
Tagged: #run #javascript #iframe
ADD COMMENT
Topic
Name
2+1 =