2013-02-28 37 views

回答

0

你可以讓你的「瀏覽」按鈕調用的onClick javascript函數或做一個動作提交即

<form action="JavaScript:navigate()">...</form> 

爲函數本身,你可以設置一個ID爲iframe中設置iframe網址從而可以被javascript用來改變URL的位置。

<script> function navigate(){ window.frames['Iframe'].document.location.href = document.getElementByID('newLink').value; } </script> 

和iframe中做到:

<iframe id="Iframe" src=""></iframe> 

因此,最終的代碼應該是這樣的。

<html> 
    <head> 
    <title>iFrame</title> 
    <script> 
    function navigate(){ 
window.frames['Iframe'].document.location.href = document.getElementByID('newLink').value; 
}  
</script> 
    </head> 
    <body> 
    <form action="JavaScript:navigate()">URL: <input type="text" id="newLink"> 

 <iframe id="Iframe" src=""></iframe> 


    </body> 
    </html> 
+0

對不起,你能告訴我每一個元素(按鈕,形式,幀)單個腳本會是什麼? THX – aRandomDeveloper 2013-02-28 01:41:10

+0

我已更正它 – 2013-02-28 02:03:03

+0

我已嘗試使用該代碼,但iframe無法導航到表單中的網址。 :O thx – aRandomDeveloper 2013-03-28 04:06:18