0

I have a form with one input where you type the URL of the website, then the URL should be sent to the iframe which is on the same web page and it should iframe the URL. Heres the code I got currently when I type http://example.com into the URL input it gives me the error, cannot GET /my_frame%22?Url=http%3A%2F%2Fexample.com

    <html>
      <head>
        <title>Form Iframe Demo</title>
      </head>
      <body>

       <form action=my_frame" >
        <input type="text" name="Url" value="http://" />
        <input type="submit" />
      </form>
<--Iframe should receive url from the form and then Iframe it -->
        <iframe name="my_frame" src="Url" width="860px">
       </iframe>
      </body>
    </html>

Have tried screwing around with it but it's running me up the wall

I would expect it to have an iframe of http://example.com but I get an error

Jack Bashed
  • 57
  • 1
  • 10
  • I'm not sure if that's what you are looking for, but that https://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe may help a bit – Voodu May 15 '19 at 22:07
  • I saw that earlier I'm afraid it didn't work, but the answer I marked worked perfectly for me. – Jack Bashed May 16 '19 at 01:13

1 Answers1

-1
<html>
<head>
        <title>Form Iframe Demo</title>
      </head>
      <body>      
        <input type="text" name="Url" id="url" value="https://j-mrad.github.io/" />
        <button onClick="LoadURL();" >Load URL</button>
        <br><br>       
        <iframe id="my_frame" src="https://www.w3schools.com" width="600px" height="500px">
        </iframe>       
       <script type="text/javascript">
       function LoadURL(){
       document.getElementById("my_frame").src=document.getElementById("url").value;
       }

       </script>

      </body>
    </html>