如何检测iframe提交点击父级 [英] how to detect the iframe submit click on parent
本文介绍了如何检测iframe提交点击父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有iframe登录输入密码和提交按钮的html页面......现在我如何在我的父母页面上确定调用iframe的提交或者调用父页面上的提交... ...
i have a html page with iframe having login input n password and submit button...... now how i determine on my parents page that the submit of iframe is called or the submit on parent page is called ......
推荐答案
您好,请关注此示例:
父页面:
Hello, please follow this sample:
Parent page:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function alert_me() {
alert('hello this is parent');
}
</script>
</head>
<body>
<iframe src="iframePage.aspx" width="800px" height="600px">
</iframe>
</body>
</html>
iframe页面(子页面) :
Iframe Page( Child Page):
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function ClickMe() {
parent.alert_me('hello there!');
}
</script>
</head>
<body>
<br/>
<br/>
<input type="button" value="Click me" id="button_click" onclick="ClickMe()"/>
</body>
</html>
这对我来说不太老实。如果两个来源都属于您,请避免使用iframe。但请查看以下网址...
首先查阅同源政策: http://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_DOM_access [ ^ ]。
请阅读这里非常详尽的教程: http://stackoverflow.com/questions / 3076414 / way-to-circum--same-origin-policy [ ^ ],也可以观看此截屏视频。 http://alexsexton.com/blog/2011/06/breaking-the -cross-domain-barrier-screencast / [ ^ ]
This looks not too honest to me. If both sources are yours, avoid using iframe. But look around on the following urls...
First consult the "same origin policy": http://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_DOM_access[^].
Than read the really exhaustive tutorial here: http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy[^], and maybe watch this screencast too. http://alexsexton.com/blog/2011/06/breaking-the-cross-domain-barrier-screencast/[^]
这篇关于如何检测iframe提交点击父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文