Solved

getting focus for a frame

Posted on 2004-08-27
8
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

690 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