2017-11-20 11 views
0

私はjavascriptのルーキーなので、onclickイベントを使用してjavascript関数を呼び出しています。その後、document.write()でphp関数を呼び出しています。私のプログラムでは、4つのフレームがあります。リンクテキストは2番目のフレームに印刷されているので、document.write(); 3番目のフレームで出来ますか??もしそうなら、私はこれをどのように達成できますか?ありがとうございます。javascriptにターゲットを与えることができません。document.write();

**js.php** 

<html> 
    <head> 
    </head> 
    <body> 
    <?php 
     $variable="link"; 
     for($i=1; $i<4; $i++) 
     { 
      echo "<a id='demo' href='' ondblclick='trial();'>".$variable."<br></a>"; 
      if($i==3) 
      { 
       break; 
      } 
     } 
    ?> 

    <script> 
     function trial() 
     { 
      //var parameter1="<?php echo $i ?>"; 
      //document.write(parameter1); 
      parent.table.location.document.write("<?php include 'linkjs.php'; hello($i); ?>"); 
     } 
    </script> 
    </body> 
</html> 

**linkjs.php** 

<?php 

    function hello($num) 
    { 
     echo $num; 
    } 

?> 

**frame.php** 

<!DOCTYPE html> 
<html> 

    <frameset rows="13%,87%,*%"> 
     <frame src="" scrolling=no > 
     <frameset cols="20%,80%,*%" > 

      <frame src="js.php" name="tree" > 

      <frameset rows="40%,60%,*%"> 
       <frame src="" name="table" scrolling=yes > 
       <frame src="" name="graph" scrolling=no > 
      </frameset> 

     </frameset> 
    </frameset> 

</html> 

答えて

0

フレーム名をjs変数に格納し、次にvariable_name.document.write();を保存する必要があります。 thats that ...

<script> 
    function trial() 
    { 
     var framename=parent.frames['framename']; 
     framename.document.write("<?php include 'linkjs.php'; hello($i); ?>"); 

    } 
</script> 
関連する問題