0

I am developing a page in with a text box, a submit button, and an iframe.

The URL should be put in the text box. Upon hitting the button, the result should appear in the iframe.

How do I do this?

Jim Counts
  • 11,812
  • 8
  • 40
  • 63

2 Answers2

0

You should not need JavaScript at all. Set the target attribute of your form to the name of the frame, and it will load there.

See also the duplicate How do you post to an iframe?.

Community
  • 1
  • 1
Bergi
  • 513,640
  • 108
  • 821
  • 1,164
0

Here is a quick solution for now using js

 <form target="#" name="iframeform" action="post">

     <input type="text" value="http://" name="framefood" id="framefood" /><br />
     <button id="feedframe" onclick="completeFrame(); return false;">Send</button><br /><br />
     <iframe id="feedme" width="600" height="400"></iframe>
 </form>
 <script>

     var completeFrame = function(e){
         var feidlId = document.getElementById("framefood");
         var frameSrc    =   feidlId.value;
         var frameId = document.getElementById("feedme");
         frameId.src =   frameSrc;
     }

 </script>
Simon Davies
  • 3,574
  • 8
  • 37
  • 67