日期:2014-05-17  浏览次数:20651 次

在<iframe>内嵌窗口中修改父窗口css属性以及调用js代码
 father.html  
  <HTML>  
  <HEAD>  
  <TITLE>   New   Document   </TITLE>  
     <script language="JavaScript">  
        function   fatherSay(){  
           alert("father method!");       
        }  

        function callSon(){
           myFrame.window.sonSay(); //父窗口调用子窗口的js方法
        }
        
         function show(){
              window.frames["myFrame"].document.getElementById ("myH1").innerHTML = "http://sbear.iteye.com";//(Firefox下)父窗口修改子窗口的css属性
     // IE下的调用方法myFrame.myH1.innerText="http://sbear.iteye.com";
          }
     </script>  
  </HEAD>  
  <BODY> 
   <h1 id="myH1">ha</h1> 
   <iframe  src="son.html" name="myFrame"></iframe>  
  </BODY>  
  </HTML>   


  son.html  
  <HTML>  
  <HEAD>  
    <script language="javascript">
     function sonSay(){
       alert("son method~");
     }  

     function callFather(){
        parent.fahterSay(); //子窗口调用父窗口的js方法 
      } 

    function show(){
       parent.document.getElementById("myH1").innerHTML = http://sebar.iteye.com; //(Firefox下)子窗口修改父窗口的css属性
       //IE下的方法parent.myH1.innerText="http://sebar.iteye.com";
     }
   </script>  
  </HEAD>  
  <BODY>  
        <h1 id="myH1">ha</h1>
  </BODY>  
  </HTML>