473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Giving Focus to the contents of an IFrame

I have an intranet page which has an iframe which links to a number of
different possible .NET pages.

In one of the embedded .NET pages (and soon to be others) we want to be

able to capture keystrokes in order to link to other apps. we do this
by setting document.onkeydown to a function which handles the various
possibilities.
The problem I have is that when the intranet page loads with my .NET
page in its iframe, focus is not given to the .NET page, and so in
order for the page to capture keystrokes you have to click on the
contents of the iframe, which is both clunky and (it seems to me)
unnecessary.
How do I automatically give focus to the contents of the iframe when it

loads up? I've tried putting the following script at the bottom of the
intranet page itself, but this doesn't seem to work:
<script
language='javascript'>document.getElementById("con tentarea").focus();</scri*pt>

("contentarea" is the name of the iframe which contains the .NET app).
Can anyone tell me what I'm doing wrong?
Thanks for any help you can give..
Mike.

May 30 '06 #1
1 2788

Mike wrote:
<script
language='javascript'>document.getElementById("con tentarea").focus();</scri*pt>

("contentarea" is the name of the iframe which contains the .NET app).


In order to get element by id you need set id="contentarea" but not
name="contentarea".

If it is a simple typo during the posting then try following code (it
works both IE6 and Firefox):
var fr = document.getElementById("contentarea");
if (document.all) //IE
fr.document.body.focus();
else //Firefox
fr.contentDocument.body.focus();

May 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Clive Moore | last post by:
I am trying to grab the focus of a popup window with a word plugin showing a rtf document using the following code. viewerWindow = window.open("6564641.rtf", "test"); viewerWindow.focus(); ...
4
by: Nick Wedd | last post by:
I have a test page http://www.files.maproom.org/00/12/q/w.html which almost does what I want. The idea is that, when you hover the mouse over one of the dates near the top of the page, it...
2
by: davemitc | last post by:
How do I focus() to a form-field, from a iframe - to its parent frame?
1
by: Testing12340 | last post by:
Hello!, I have this well, little IE issue. I'm showing hiding div's (containing IFRAMES), however, for some reason in IE one of the iframe contents allow me to click them (the last one allows me...
1
by: Mike | last post by:
I have an intranet page which has an iframe which links to a number of different possible .NET pages. In one of the embedded .NET pages (and soon to be others) we want to be able to capture...
1
by: jaktharkhan | last post by:
Hi, I really really need help in trying to figure out how can I do a CloneNode on an Iframe where the cloned IFRAME clones with all its contents?. Basically what I am doing is dynamically building...
1
by: appleseed | last post by:
I'm having some problems on IE with a small editor I'm building. The source of the problem is the following: Consider having an iFrame with designMode="on" in which you select some text. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.