Sign in to follow this  
drackill

[java] Giving applets Focus first

Recommended Posts

Just a random question but just working on a simple pong game and when I load the applet within a html page, I firstly have to click on the applet to do anything on it. I know this isn't a major problem but just wondering if there is a way so when the page loads the applet is straight away under the player control? Unsure if this would be better placed within the html forum but hopefully it should be ok here. Thanks in advance. Nate

Share this post


Link to post
Share on other sites
irrc you can use the focus function of the DHTML applet tag in order to give focus to the applet though I am not sure if this will cause java to set the focus.

Example:

<applet
id="myapplet_id"
code="myapplet"
archive="mypackage.jar"
width=600
height=400
>
Get java stupid!
</applet>





And the javascript for the page

onload = document.all("myapplet_id").focus();





I think that should help! Let me know if that works!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this