View Full Version : submit url to iframe from input text field

11-10-2004, 11:57 AM
This is probable very easy, I've tried with normal html and am unable to get my head around it.

I would like to in some way replicate how a web browser works.

I have a form entry field with a submit button at the top of the page.
Under that I have an iframe.

I copy the url http://www.bbc.co.uk into the entry field, click submit and the iframe updates with the website. Have looked around and haven't found anything similar.

Code so far....

<form target="myURL">
<input type="text" name="goTo">
<input type="submit" name="submit" value="submit">
<iframe src="" name="myURL" border="0" frameborder="0" width="768" height="354"></iframe>

Thanks in advanced.

Death = $Mill

11-10-2004, 12:58 PM
try adding a function to the submit button

function submitURL() {

//get the URL
var url = document.getElementById("goTo").value;

//set the iFrame to the url above
myURL.document.location.href = url;


your HTML would look like:

<input type="text" name="goTo" id="goTo">
<input type="button" value="load url" onclick="submitURL()">
<iframe name="myURL" border="0" frameborder="0" width="768" height="354"></iframe>

Hope that helps :)

12-08-2004, 07:05 PM
homer thanks for this, work but for one little thing, if I already have a web site loaded in the iframe and I try and load another site it throws me an Access Denied javascript error message - but if I start off with the iframe "about:blank" then search its fine - then if i try again; again i get the error.

Is there any way around this?

- Death = $Mill

12-09-2004, 05:38 AM
<form target="myURL" onsubmit="this.action=this.goTo.value">
<input type="text" name="goTo">
<input type="submit" name="submit" value="submit">
<iframe src="" name="myURL" border="0" frameborder="0" width="768" height="354"></iframe>

08-21-2009, 01:45 AM
Very Nice i apply already but i amconfuse if i wantto type My URL why all my page will come up. Why not my link ? For Example i want to type http://make-moneyonline.com whole page will come up. Can you teach i really want the URL will come up not whole page. For example i will type and submit http://make-moneyonline.com i want my link http://make moneyonline.com will be appear not the whole page. Please teach me how if you have time please email me marexecutive@gmail.com new york. Thanks in advance

03-12-2010, 04:42 PM
I used this code to do a little Iframe page, but for some reason, the if statement, even though the condition is recognized correctly, does not work for me.

What I'm basically trying to do is to check if the input has HTTP:// in it, and if it does not to add it to the URL and then display the page.
The code seems to work but if the HTTP:// is omitted - it still says that the "system cannot find file specified".
What am I missing?
It seems like the "myURL.document.location.href = url;" string is causing issues/not working as soon as the <Onsubmit="this.action=this.goTo.value"> is added

Here is the code:


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/javascript">
var url;
function submitURL() {
url = document.getElementById("goTo").value;
check = url.substr(0,7);
check = check.toLowerCase();
if (check != "http://")
url = "http://"+url;
myURL.document.location.href = url;
myURL.document.location.href = url;


<form target="myURL" onsubmit="this.action=this.goTo.value">
<b>Address:</b>&nbsp;<input type="text" name="goTo" onchange="submitURL()" size="90%" id="goTo">
<iframe name="myURL" border="0" frameborder="0" width="100%" height="90%"></iframe>