Syntax error Cross domain HTML5 iframe issue

Cross domain HTML5 iframe issue



Use the postMessage method for transferring data across different domains.

Example

You can try the following code snippet to solve the cross-domain HTML5 iframe issue −

// Using postMessage()
window.onmessage = function(e) {
   e.source.postMessage(document.body.innerHTML, e.origin);
};
window.onmessage = function(event) {
   alert(e.data);
};
// fire
document.getElementById('frame1').contentWindow.postMessage('','*');
Updated on: 2020-06-25T06:25:26+05:30

515 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements