2

我是一个菜鸟,并试图从 Iframe 中检索 HTML 列表,并通过按下父框架内的按钮来更新父框架内的列表。请帮忙,我一直在检索错误“未定义更新列表”,我知道我一定做错了什么,目前感觉想把头撞在墙上并请求帮助

<html> 
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>

<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById('Framed');
var Newlist = OldList.contentWindow;
document.getElementById('FileList').innerHTML= Newlist;}


</script>

</style>
</head>
<body style="color:white">
<div id="FileList">
<select>
<option>Push Refresh</option>
</select>
</div>
<iframe NAME="Framed" id="Framed" src="DirectoryPreview.php" width="250" height="100">
</iframe>
<br>
<button onclick="UpdateList()">Push to refresh</button>
</body>

           **Correction for the above, hope it helps others struggling**


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
</style>
<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById('Framed');
var NewList = OldList.contentDocument || iframe.contentWindow.document;
var Contents = NewList.getElementById('List').value;
document.getElementById('FileList').innerHTML= Contents;}
</script>

</head>
<body style="color:Black">
<div id="FileList">
<select>
<option>Push Refresh</option>
</select>
</div>
<iframe NAME="Framed" id="Framed" src="DirectoryPreview.php" width="250" height="100">
</iframe>
<br>
<button onclick="UpdateList()">Push to refresh</button>
</body>
</html>
4

1 回答 1

1

您的 javascript 嵌入style tag其中!!!!您怎么能期望它执行???

更改:-

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
</style> 

<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById("Framed");
var Newlist = OldList.contentWindow;
document.getElementById("FileList").innerHTML= Newlist;
}
</script>
于 2012-09-04T10:01:42.957 回答