473,378 Members | 1,429 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,378 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 2812

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...
2
by: bs9999 | last post by:
I'm using IFRAME to connect back to my ASP.NET page in order to fetch the FreeBox HTML Editor html contents and scripts (i do this apprach because the html editor is fairly heafty to send to the...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.