【发布时间】:2013-08-05 14:41:45
【问题描述】:
我有以下两个 html 文件。在PassValueIFrame.html 中,我有一个引用inputForm.html 的iframe。另外,我在PassValueIFrame.html 中有一个隐藏字段,我试图在inputForm.html 中检索它的值,但没有得到它的值,它警告为'undefined'。我在这里做错了吗?请帮帮我。
PassValueIFrame.html
<html>
<head>
<title>IFrame Example</title>
</head>
<body>
<input type="hidden" class="Language" value="English">
<iframe name="iframe" id="iframe_id" src="inputForm.html" height="150" >
</iframe>
</body>
</html>
inputForm.html
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script language="javascript">
$(document).ready(function() {
alert($(this).parent().find('.Language').html());
});
</script>
<title>IFrame Child Example</title>
</head>
<body>
<h1> Iframeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee </h1>
</body>
谢谢!
【问题讨论】:
-
这是因为它是 iframe...
-
约翰,iframe 不能从其父字段访问字段吗?
-
我想这会对你有所帮助:stackoverflow.com/q/935127/1420197
标签: javascript jquery html