在这里搜索
http://community.csdn.net/Expert/search.asp?bigclassid=0&smallclassid=304

解决方案 »

  1.   

    1.使用iframe
    //txt.html
    <html>
    <head>
    <title>txt</title>
    </head>
    <body>
    <div id="txtcom">Your txt:If you can see this, It's good!</div>
      </body>
    </html>
    //要读取的页面
    <html>
     <head>
      <title>Reader external Txt</title>
      <script language="JavaScript" type="text/javascript">
          function getTxt(txtid){
           var txtref;
           var shower = document.getElementById("txt_shower");
           if((txtid != "") && (txtid != null) ){
              txtref = self.frames[0];
              if(txtref){             
                 var txtcomref = txtref.document.getElementById("txtcom");
                 if(txtcomref){               
                    if(shower){                   
                       shower.innerHTML = txtcomref.innerHTML;
                    }
                 }
              }    
           }
          
             
          }
      </script>
     </head>
     <body>
        <p>external txt</p>
        <br>
        <div style="visibility: hidden">
        <iframe id="idtxt" src="txt.html" display="none"></iframe>
        </div>
        <br>
        <p>Show Txt</txt>
        <br>
        <div id="txt_shower"></div>
        <br>
        <input type="button" value="Show Txt" onclick="getTxt('idtxt');"/>
     </body>
    <html>2。使用javascript变量
    //txt.js
    var txt="Your txt:If you can see this, It's good!";
    //readtxt.html
    将txt.js导入页面,读取变量txt即可。