Setting the focus to an applet in a web page.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Setting the focus to an applet in a web page.

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    2

    Question Setting the focus to an applet in a web page.

    I would like to get my applet to automatically get the input focus whenever the web page is loaded, so that keypresses are sent to the applet without having to click on it first. I understand that this is out of the applet's control, but the focus can be set by a script on the page. I have made various attempts at doing this e.g.:

    <html>
    <head></head>
    <body>
    <applet ......... etc.>
    </applet>
    <script language="JavaScript">
    document.applets[0].focus();
    </script>
    </body>

    I have also tried placing it in a onLoad event handler, but I've still not been able to get it working. I've tried it in a form, but that didn't work either.
    Help much appreciated....

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Just a wild guess: have you tried to have a public method in the applet, then invoke
    that method from javascript and do a requestFocus in that method. Like if
    your applet is named theApplet in the html, and the method is called getFocused()
    you could write theApplet.getFocused(); in javaScript.

    Its a wild guess though...
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center