Solved

getting focus for a frame

Posted on 2004-08-27
8
218 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
 

Author Comment

by:hapciu
ID: 11925484
COBOLdinosaur: I don't know javascript very well. please give me some sample code
thanks
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now