How can JavaScript be used to modify the content of an iFrame within the same domain?

To modify the content of an iFrame within the same domain using JavaScript, you can access the iFrame's content document using the `contentDocument` property and then manipulate its content as needed. This allows you to dynamically update the iFrame's content without needing to reload the entire page. ```javascript // Get the iFrame element var iframe = document.getElementById('myIframe'); // Access the iFrame's content document var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; // Modify the content of the iFrame iframeDoc.body.innerHTML = '<h1>New Content</h1>'; ```