faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 11 people (73%) answered Yes
Recently 7 of 10 people (70%) answered Yes


Needed: a javascript single line blank input form that opens any url thats entered in it on submit.

May 10th, 2003 04:39
Jean-Bernard Valentaten, Rick Dome,

All you need is an input-line and a submit button:
  <script language="JavaScript">
    function openUrl()
      var myUrl = document.forms['myForm'].elements['myInput'].value();
      if (myUrl.lenght > 0)
        document.location.href = myUrl;
  <form id="myForm" action="." method="get" onSubmit="openUrl();">
    <input id="myInput" type="text" size="30">
    <input id="myButton" type="submit">
That should work and I'm sure you won't have any problems integrating 
it into your page :)