 <p>Give your text box a id for example "txtInput" give your iframe a id for example "myIframe" on the button give it no navigation so it stays on current page and use the onclick="myFunction()"</p> <p>in the function you can use this (excuse me if this is slightly wrong its been a while since I have used HTML</p> <pre><code> function myFunction() { var iframe = document.getElementById("myIframe"); var input = document.getElementById("txtInput").text; //check to see if there is a valid url in the text box be carefull if there are multiple links in the text box it will put them all in and the iframe will go to 127.0.0.1 or search engine due to incorrect URL var isURL=new RegExp(/(((f|ht)(tp|tps):\/\/)[\w\d\S]+)/,g); iframe.src = input.match(isURL); } </code></pre> <p>If you do not want to mess with regular expresions you can just simply use the following.</p> <pre><code>function myFunction() { var iframe = document.getElementById("myIframe"); var input = document.getElementById("txtInput").text; iframe.src = isURL; } </code></pre>