日期:2014-05-16  浏览次数:20410 次

js iframe
我有一个iframe   连接的是一个文本文件
<iframe   id= "iframe1 "   src= "name.txt "   style= "Z-INDEX:   102;   LEFT:   214px;   WIDTH:   401px;   POSITION:   absolute;   TOP:   197px;   HEIGHT:   89px ">
</iframe>
怎么样用js把iframe   中文本文件的内容读出来

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function getText(){
alert(document.frames[ 'iframe1 '].document.body.innerHTML);
alert(document.frames[ 'iframe1 '].document.body.innerText);
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<iframe id= "iframe1 " src= "name.txt " style= "Z-INDEX: 102; LEFT: 214px; WIDTH: 401px; POSITION: absolute; TOP: 197px; HEIGHT: 89px ">
</iframe>
<INPUT TYPE= "button " value= "getText " OnClick= "getText() ">

</BODY>
</HTML>