skip to Main Content

How to send body to iFrame cross domain

How To Send Body To IFrame Cross Domain

The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one. By doing this, you ca display a secondary webpage on your main page.

iFrame can make your web page slow and pose a security risk, especially if you use content from a suspicious website.

How to send body in iFrame

<div id="container">
	<form id="loginForm" target="myFrame"  action="http://localhost/page.php" method="POST">
	<input name="If-Unmodified-Since" type="hidden" value="Tue, 1 Jan 2013 12:00:00 GMT" payload="_header"/>
	 <input type="text" name="j_username" value="login fsf" hidden="hidden" />
	 <input type="text" name="j_password" value="password" hidden="hidden" />
	 <input type="submit" hidden="hidden">
	</form>	
	<iframe name="myFrame" id="output-frame-id" src="" style="height:100%;width:100%;" title="Iframe Example"></iframe>
</div>
function formAutoSubmit () {

	var frm = document.getElementById("loginForm");

	frm.submit();

}
window.onload = formAutoSubmit;

How to allow your web page access cross domain in iFrame

To allow your web page cross domain in iFrame you need to add this code into .htaccess or you can add it in your web server configuration.

Header set X-Frame-Options "allow-from *"

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top
Search