看板 Ajax 關於我們 聯絡資訊
請問一下 有辦法通過js來access iframe內的資料嗎? 就像是下面 index.html: <script> function sendTest() { //把iframe['test']內的表單作submit } </script> <button onClick='sendTest()'> </button> <iframe src='test.html' id='test' > </iframe> test.html: <form action='handle.php' id='form1'> <input type='hidden' name='aAction' value='joasd'> </form> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.10.83.30
Fenikso:window.frames[0].document.getElementById 06/07 17:42
Fenikso:('form1').submit() 06/07 17:42
lockchou:一樓的frames[0]改成frames['test']也可以。 06/09 15:01
lockchou:若在多個iframe的情況下,以id存取比較清楚。 06/09 15:01
chiayin0409:iframe裡src是不同網站也可以這樣操作form嗎? 08/21 22:48