Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile submit url to iframe from input text field

    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">
    </form>
    <iframe src="" name="myURL" border="0" frameborder="0" width="768" height="354"></iframe>

    Thanks in advanced.

    Death = $Mill

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    try adding a function to the submit button

    Code:
    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:

    Code:
    <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

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    <form target="myURL" onsubmit="this.action=this.goTo.value">
    <input type="text" name="goTo">
    <input type="submit" name="submit" value="submit">
    </form>
    <iframe src="" name="myURL" border="0" frameborder="0" width="768" height="354"></iframe>

  • #5
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Very Nice Code

    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

  • #6
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK
    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:
    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Address</title>
    <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;
      		}
    	else
      		{
    		myURL.document.location.href = url;
      		}
    	}
    </script>
    	
    
    </head>
    
    <body>
    <form target="myURL" onsubmit="this.action=this.goTo.value">
    <b>Address:</b>&nbsp;<input type="text" name="goTo" onchange="submitURL()" size="90%" id="goTo">
    <hr>
    </form>
    <iframe name="myURL" border="0" frameborder="0" width="100%" height="90%"></iframe>
    
    </body>
    
    </html>
    Last edited by Jerzy_S; 03-12-2010 at 04:21 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •