+ 2

Text field and iframe

<html><body> <script> var theTextBox=document.getElementById("yourTextBox"); var theFrame=document.getElementById('yourFrame'); theFrame.src = theTextBox.value; </script> <input id="yourTextBox" type="text" class=input_mid placeholder="Enter" value="" name="q" size="20"></input> <iframe id="yourFrame" allowfullscreen="allowfullscreen" frameborder="0"></iframe> </body></html> 👆👆👆👆👆please Tell What Should Be done To make this Work

17th Nov 2017, 1:37 PM
KM Sanjay
KM Sanjay - avatar
5 Réponses
+ 2
You'll want to put the code from your script into its own function. Then create a button that you'll use to update the iFrame based upon the text in your text box. On the button, put onclick="yourFunction();" as one of its properties. That should do the trick for you. It appears to be limited what websites SoloLearn allows to be displayed, but if you put https://www.SoloLearn.com into the text box and hit Go!, it'll work as intended, and should work fine outside of SoloLearn. https://code.sololearn.com/WLnHRXypsMmO/#html <input id="yourTextBox" type="text" class="input_mid" placeholder="Enter" value="" name="q" size="20" /> <button onclick="updateFrame();">Go!</button> <iframe id="yourFrame" src="" allowfullscreen="allowfullscreen" frameborder="0"></iframe> <script> function updateFrame() { var theTextBox = document.getElementById("yourTextBox"); var theFrame = document.getElementById("yourFrame"); theFrame.src = theTextBox.value; } </script>
17th Nov 2017, 1:54 PM
AgentSmith
+ 1
not working
17th Nov 2017, 2:00 PM
KM Sanjay
KM Sanjay - avatar
+ 1
@Sanjay What happens on your end? It's working fine for me. However, I'm using Chrome and in the upper-right, I had to click to allow unauthorized scripts so that it would allow SoloLearn to update. Also, I had to fully type out the "https://" in front of the URL. That's easily fixed by simply adding that as a string in front of the value you're adding to the src, or just type it out manually.
17th Nov 2017, 2:06 PM
AgentSmith
+ 1
anyways thank you it's not for my reference , I have created one webview app, it's not working in that.
17th Nov 2017, 3:52 PM
KM Sanjay
KM Sanjay - avatar
0
You're welcome. Post your updated code and I'll help you figure out why it's not working in your environment.
17th Nov 2017, 5:36 PM
AgentSmith