2017-09-19 35 views
0

我想知道這裏有人能幫助我嗎?我有一個包含多個框架的頁面,其中一個框架frame_b只是一個帶有3個HTML表單的HTML頁面,用於提供按鈕。 - 通常這將繼續使用數據庫內容生成的列表來填充其他幀。HTML - 如何在按鈕單擊頁面時刷新多個框架?

但是,有人可以告訴我,點擊其中一個按鈕還可以將frame_c,d,e & f的內容重置回原始框架集頁面嗎?並請按下我們的表單/按鈕的動作?

下面是frame_c的HTML代碼頁:

<html> 
 
    <head> 
 
     <title>Button Ribbon</title> 
 
     <meta charset="UTF-8"> 
 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    </head> 
 
    <body style="background-color: forestgreen;"> 
 
     <table> 
 
     <tr> 
 
     <td> 
 
     <form action="phplist1.php" target="frame_c"> 
 
     <input type="submit" value="Clients" /> 
 
     </form> 
 
     </td> 
 
     <td> 
 
     <form action="phplist2.php" target="frame_c"> 
 
     <input type="submit" value="Horses" /> 
 
     </form> 
 
     </td> 
 
     <td> 
 
     <form action="employees.html" target="frame_c"> 
 
     <input type="submit" value="Employees" /> 
 
     </form> 
 
     </td> 
 
     </tr> 
 
     </table> 
 
    </body> 
 
</html>

及以下的框架代碼:

<html> 
 
    <head> 
 
     <title>Frameset</title> 
 
     <meta charset="UTF-8"> 
 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    </head> 
 
     <frameset rows="20%,5%,5%,*"> 
 
     <frame src="FrameHeader.html" name="frame_a" frameborder="0" scrolling="no"> 
 
     <frame src="buttonribbon.html" name="frame_b" frameborder="0"> 
 
     <frameset cols="*,*"> 
 
      <frame src="blankgreen.html" name="frame_c" frameborder="0">  
 
      <frame src="blankgreen.html" name="frame_d" frameborder="0"> 
 
     </frameset> 
 
     <frameset cols="60%,40%"> 
 
      <frame src="blank.html" name="frame_e" frameborder="0">  
 
      <frame src="blank.html" name="frame_f" frameborder="0"> 
 
     </frameset> 
 
</html>

許多謝謝, 格雷厄姆

.....後來我加了以下內容:

<form action="phplist1.php" target="frame_c"> 
 
      <script type="application/javascript"> 
 
       "use strict"; 
 
       var list=['frame_c', 
 
        'frame_d', 
 
        'frame_e', 
 
        'frame_f', 
 
       ]; 
 
    
 
      for(var i=0; i<list.length; i++){ 
 
      document.getElementByName(list[i])[0].contentWindow.location.reload(); 
 
      } 
 
      </script> 
 
     <input type="submit" value="Clients" />

但它似乎沒有正常工作呢。任何援助讚賞。

非常感謝,

+0

你好,JS解決方案[像這樣](https://stackoverflow.com/q/86428/2194007)適合你嗎? – rath

+0

嗨,太棒了,謝謝!我已經按照下面的方式部署了它,但它似乎沒有工作,phplist仍然可以正常加載,但是hte幀沒有被清除。這是你期望它被部署的方式嗎? –

回答

0

讓您的幀識別符列表:

"use strict"; 
var list=['frame_a', 
    'frame_b', 
    'frame_c', 
    'frame_d', 
    ]; 

,然後遍歷它們。在你的榜樣,你沒有ID的,所以我會用getElementsByName

for(var i=0; i<list.length; i++){ 
    document.getElementByName(list[i])[0].contentWindow.location.reload(); 
} 

根據some commentscontentWindow可能無法使用Chrome上,所以你需要contentDocument代替。