juha: HTML-Cursor setzten (setfocus)???

Hallo Zusammen

Wenn ich eine Seite (HTML) mit einem Eingabefeld aufrufen möchte, soll der Cursor automatisch in das Eingabefeld gesetzt werden, so dasss ich die Maus oder Tastatur nicht gebrauche!?

Ist dies nur mit JAVA möglich, nicht mit HTML? Ich kenne mich mit JAVASCRIPT-JAVA überhaupt nicht gut aus!

Wie geht denn so was, in der Doku wurde ich auch nicht schlau!
Hier noch mein HTML-Code

<html>
<head></head>
<body bgcolor='#E7F7FF'><font face='arial'>

<form method="get" action="/cgi-bin/zeit.cgi">
  <table border="0" cellspacing="0" cellpadding="3">

<tr>
      <td bgcolor="#E7F7FF">Name</td>
      <td bgcolor="#E7F7FF"><input type="text" name="search" size="20" value=""></td>
    </tr>
    <tr>
      <td></td>
      <td><input type="submit" value="Suchen" onClick="self.location.href='/cgi-bin/zeit.cgi'" name="B1"></td>
   <input type="hidden" name="mode" value="person">
    </tr>
  </table>
  </form>

</body>
</html>

Mit freundlichen grüssen
Juha

  1. Hallo,

    <html>
    <head>

    <script type="text/javascript">
       function fokusieren()   {
       document.Formularname.search.focus();
       }
       </script>
    </head>

    <body onLoad="fokusieren()" bgcolor='#E7F7FF'><font face='arial'>

    <form name="Formularname" method="get" action="/cgi-bin/zeit.cgi">

    <table border="0" cellspacing="0" cellpadding="3">

    <tr>
          <td bgcolor="#E7F7FF">Name</td>
          <td bgcolor="#E7F7FF"><input type="text" name="search" size="20" value=""></td>
        </tr>
        <tr>
          <td></td>
          <td><input type="submit" value="Suchen" onClick="self.location.href='/cgi-bin/zeit.cgi'" name="B1"></td>
       <input type="hidden" name="mode" value="person">
        </tr>
      </table>
      </form>

    </body>
    </html>

    habs zwar nicht getestet, aber so sollte es gehen.

    1. Die body Zeile wurde auch verändert, hab vergessen die Pfeile zu entfernen

      <body onLoad="fokusieren()" bgcolor='#E7F7FF'><font face='arial'>

      1. Hallö

        Nun habe ich es wie folgt, doch der Cursor ist noch nicht im Eingabefeld per Start der HTML-Seite?

        cu juha

        <html>
        <head>

        <script type="text/javascript">
           function fokusieren()
           {
          document.personsuchen.search.focus();
           }
           </script>
        </head>
        <body onLoad="fokusieren()" bgcolor='#E7F7FF'><font face='arial'>

        <form name="personsuchen" method="get" action="/cgi-bin/zeit.cgi">
         <table border="0" cellspacing="0" cellpadding="3">

        <tr>
          <td bgcolor="#E7F7FF">Name</td>
          <td bgcolor="#E7F7FF"><input type="text" name="login" size="20" value=""></td>
            </tr>
            <tr>
               <td></td>
               <td><input type="submit" value="Suchen" onClick="self.location.href='/cgi-bin/zeit.cgi'" name="B1"></td>
               <input type="hidden" name="mode" value="person">
            </tr>
            </table>
            </form>

        </body>
        </html>

        1. hallo juha!

          <html>
          <head>

          </head>
          <body onLoad="document.personsuchen.login.focus()" bgcolor='#E7F7FF'><font face='arial'>

          <form name="personsuchen" method="get" action="/cgi-bin/zeit.cgi">
           <table border="0" cellspacing="0" cellpadding="3">

          <tr>
            <td bgcolor="#E7F7FF">Name</td>
            <td bgcolor="#E7F7FF"><input type="text" name="login" size="20" value=""></td>
              </tr>
              <tr>
                 <td></td>
                 <td><input type="submit" value="Suchen" onClick="self.location.href='/cgi-bin/zeit.cgi'" name="B1"></td>
                 <input type="hidden" name="mode" value="person">
              </tr>
              </table>
              </form>

          </body>
          </html>

          kopier dir mal diesen code und probier es nocheinmal!
          habs getestet und es geht :o)

          mfg Roman

          1. Hallö

            Danke vielmals bei mir geht es auch, allerdings habe ich noch einen kleinen hacken!

            <td bgcolor="#E7F7FF">Name</td>
              <td bgcolor="#E7F7FF"><input type="text" name="login" size="20" value=""></td>

            Ich würde dieses Feld gerne verw_login taufen, warum kann ich das nicht einfach husch ändern, warum geht dann die Cursor-Geschichte gleich nicht mehr? Sollte doch kein Problem sein?

            cu juha

            1. hi!

              <body onLoad="document.personsuchen.verw_login.focus()" bgcolor='#E7F7FF'><font face='arial'>

              <tr>
              <td bgcolor="#E7F7FF">Name</td>
              <td bgcolor="#E7F7FF"><input type="text" name="verw_login" size="20" value=""></td>

              mußt nur das input-feld ändern und im body auch...

              mfg Roman

              1. Tja, klein aber oho.. ;-)
                Danke!

                cu juha

                hi!

                <body onLoad="document.personsuchen.verw_login.focus()" bgcolor='#E7F7FF'><font face='arial'>

                <tr>
                <td bgcolor="#E7F7FF">Name</td>
                <td bgcolor="#E7F7FF"><input type="text" name="verw_login" size="20" value=""></td>

                mußt nur das input-feld ändern und im body auch...

                mfg Roman

  2. hallo juha!

    <form method="get" action="/cgi-bin/zeit.cgi">

    du mußt nur dem form einen name geben:
    <form name="formular" method="get" action="/cgi-bin/zeit.cgi">

    <body bgcolor='#E7F7FF'>

    und dann den body-tag auf folgendes ändern:
    <body onload="document.formular.search.focus()" bgcolor='#E7F7FF'>

    mfg Roman

    1. Hallo zusammen

      hallo juha!

      <form method="get" action="/cgi-bin/zeit.cgi">

      du mußt nur dem form einen name geben:
      <form name="formular" method="get" action="/cgi-bin/zeit.cgi">

      <body bgcolor='#E7F7FF'>

      und dann den body-tag auf folgendes ändern:
      <body onload="document.formular.search.focus()" bgcolor='#E7F7FF'>

      mfg Roman

      habe nun alle drei Varianten ausprobiert, aber funktioniert hat nichts.
      Bei der body zeile...

      <body onload="document.formular.search.focus()" bgcolor='#E7F7FF'>

      muss ich doch bei formular der name der html-Seite angeben, also z.b. sucheperson und nicht sucheperson.htm

      muss ich hier sonst noch was einfügen? (z.B. bei document)?

      cu
      juha

  3. Hallo,

    Wenn ich eine Seite (HTML) mit einem Eingabefeld aufrufen möchte, soll der Cursor automatisch in das Eingabefeld gesetzt werden, so dasss ich die Maus oder Tastatur nicht gebrauche!?

    Ist dies nur mit JAVA möglich, nicht mit HTML? Ich kenne mich mit JAVASCRIPT-JAVA überhaupt nicht gut aus!

    Wie geht denn so was, in der Doku wurde ich auch nicht schlau!
    Hier noch mein HTML-Code

    <html>
    <head></head>

    <body bgcolor='#E7F7FF'><font face='arial'>

    <form method="get" action="/cgi-bin/zeit.cgi">
      <table border="0" cellspacing="0" cellpadding="3">

    <tr>
          <td bgcolor="#E7F7FF">Name</td>
          <td bgcolor="#E7F7FF"><input type="text" name="search" size="20" value=""></td>
        </tr>

    <body onload="document.forms[0].search.focus()">

    MfG, Thomas