简体   繁体   中英

Read Form Fields of IFRAME - Cross Domain

My html page looks like below.. what i need done is if someone types something in ApplicantInfo1$FirstName field outside of IFRAME- I dont have any control on the url which is opened in Iframe. Is this possible using Json or Javascript .

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
First Name : 
<input name="ApplicantInfo1$FirstName" type="text" maxlength="30" id="ApplicantInfo1_FirstName" title="First Name" class="nonnumeric" minlength="2" style="width:200px;" /> 
<br />
<iframe id="progressive" src="https://www.progressivelp.com/onlineapplication/onlineapplication.aspx?sid=Metro2674957490&kid=1" width="940" height="1200" scrolling="no" style="border:none;"></iframe>
</body>
</html>

This is not possible due to the same origin policy that browsers enforce.

Without that policy, anyone could write a web page that opens your online banking in an iframe and reads anything it wants from that HTML. I think we can agree that this would be a huge security risk, so that in general the same original policy (SOP) is a Good Thing.

A common way to work around this limitation is by introducing a proxy page on your server. This proxy page can then retrieve the remote web page on your behalf and return its contents to the browser. This ensures both HTMLs come from the same domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM