-1

I need a simple html code so that a visitor to my website can type in a textfield what website they would like to visit next and click GO and they are taken there.

I can't seem to find how to do this anywhere. Can't even find any websites that have a similar code.

Jonas
  • 121,568
  • 97
  • 310
  • 388
SiiN
  • 7
  • 3
  • Possible duplicate of [How do I redirect with Javascript?](http://stackoverflow.com/questions/4744751/how-do-i-redirect-with-javascript) – ioneyed Nov 30 '16 at 02:34

1 Answers1

0

Here is a quick implementation that will set it based on the text field value. I would suggest putting in validation and much more.

function goToUrl(form){
  window.location = form.url.value
}
<form onsubmit="goToUrl(this)">
  <input type="text" id="url" />
  <button type="submit">Go to URL</button>
</form>
ioneyed
  • 1,052
  • 7
  • 12
  • Thank you. I'm not really good at coding anything but HTML. Can you tell me what this kind of code might be called so I can look around and maybe find a better version of the script? I've searched around but can't find it since I don't even know what its called. – SiiN Nov 30 '16 at 03:14
  • the function is JavaScript which is the interaction layer for HTML that allows programmatic actions based on events. – ioneyed Nov 30 '16 at 03:20