Solved

getting focus for a frame

Posted on 2004-08-27
8
221 Views
Last Modified: 2010-04-06
hi,

I have a html page with 3 frames. one of the frames contains an applet. when you open the page i would like the keyboard focus to be directed to the frame with the applet (so you can just start typing in a text field). how can i do that ?

thanks
0
Comment
Question by:hapciu
8 Comments
 
LVL 10

Expert Comment

by:rockmansattic
ID: 11918257
this should work

http://developer.irt.org/script/57.htm


Rockman
0
 

Author Comment

by:hapciu
ID: 11918396
there are 2 solutions there.. they don't work for me. maybe beacause of my applet ?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11921371
You probaly hve to give the applet an id so you can reference it through the DOM with:

top.frames['framename'].document.getElementById('appletid').focus();

OR yo may have to reference a functin on th epage with the applet to set focus with:

top.frames['framename'].yourfunction();

Cd&
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:hapciu
ID: 11925484
COBOLdinosaur: I don't know javascript very well. please give me some sample code
thanks
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11926468
Post a link to the page or your code, so I have someidea of what you are doing.

Cd&
0
 

Author Comment

by:hapciu
ID: 11936969
index.html:

************************
<HTML>
<HEAD>
      <SCRIPT language='JavaScript'>
            function expand(p) {
                  parent.down.cols = p + '%, ' + (100-p) + '%';
            }
            
      </SCRIPT>
</HEAD>
<FRAMESET rows='65%, 35%'>
      <FRAMESET id='up' cols='*, 350' marginwidth='0' marginheight='0' scrolling='no' border='0'>
            <FRAME name='apl' src='apl_frame.html' title='Apl' marginwidth='0' marginheight='0' scrolling='no'>
            <FRAME name='tv' src='tv.html' title='TV' marginwidth='0' marginheight='0' scrolling='no'>
      </FRAMESET>
      <FRAMESET id='down' cols='*, *'>
            <FRAME name='nts' src='nts_frame.html' title='Nts'>
            <FRAME name='cnt' src='cnt_frame.html' title='Cnt'>
      </FRAMESET>
</FRAMESET>
</HTML>

************************

and apl_frame.html:

************************

<APPLET code="MyApplet"
archive="apl.jar" width="100%" height="100%">
/APPLET>

****************************

and as soon as my page loads, I want my applet in apl_frame.html to get focus - because in the applet i have a text field that should get focus (but it doesn't)

thanks
0
 
LVL 2

Expert Comment

by:Epistemo
ID: 11948120
Did you try <body onLoad="window.focus()">  in the specific page?

Or try this ...

<body onload="location.hash = 'SuperApplet';">
<applet id="SuperApplet" code="MyApplet" archive="apl.jar" width="100%" height="100%"></applet>


0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 11954911
in index.html do the frameset tag this way:

<frameset rows="65%,35%"
   onload=top.frames['Apl'].document.focus()">

But it may not work because the applet page is not a valid HTML page.  You will probably need to do the page this way:

<html>
<head></head>
<body>
<APPLET code="MyApplet"
archive="apl.jar" width="100%" height="100%">
</APPLET>
</body>
</html>


and it might also be necessary to put an id on the applet:

<APPLET id="xxx" code="MyApplet"
archive="apl.jar" width="100%" height="100%">
</APPLET>

The framset line would need to be:

<frameset rows="65%,35%"
   onload=top.frames['Apl'].document.getElementById('xxx').focus()">


Cd&
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question