我想获取驻留在iFrame中的输入字段的文本。 我的代码是: 父HTML:
<!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>
<script>
function check(){
var x=window.frames['childme'].document.getElementById('checkme')
alert(x);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<button type="button" onclick="check()">check</button>
<input type="text" id="setcheck">
<div style="width:auto; height:800px;">
<iframe src="child.html" id="childme">
</iframe>
</div>
</body>
</html>
儿童HTML:
<!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>
<input type="text" id="checkme" value="hello">
</body>
</html>
问题是我的警报框根本没有显示,并且没有显示任何内容!是不是有人能帮助我,我做错了什么?