473,387 Members | 1,420 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,387 software developers and data experts.

What is wrong with Focus on Firefox?

WH
<html>
<head>
<style type="text/css">
html, body
{
overflow: hidden;
}
</style>
</head>
<body onload="showit()" leftMargin="0" rightMargin="0" topMargin="0"
marginwidth="0"
marginheight="0">

<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
FRAMEBORDER="0"></iframe>
<script type="text/javascript" language="javascript1.2">
<!--
function showit() {
myframe.focus();
//some other codes here

}

-->
</script>
</body></html>

In IE, works perfectly, in firefox, not automatically focus.
Jul 23 '05 #1
7 13246
WH wrote:
myframe.focus();


Where's the "myframe" variable defined and initialized? Ah, it's the ID
of an element, not a variable - then use a standard way to get a handle
to the element, not an IE-ism:-)

Check the FAQ 4.41:

<URL:http://jibbering.com/faq/#FAQ4_41>
Jul 23 '05 #2
WH
WH wrote:
myframe.focus();


Where's the "myframe" variable defined and initialized? Ah, it's the ID
of an element, not a variable - then use a standard way to get a handle
to the element, not an IE-ism:-)

Check the FAQ 4.41:

<URL:http://jibbering.com/faq/#FAQ4_41>

No, notwrking. Test this

<html>
<head>
<style type="text/css">
html, body
{
overflow: hidden;
}
</style>

</head>
<body onload="document.getElementById('myframe').focus() ;" leftMargin="0"
rightMargin="0" topMargin="0" marginwidth="0" marginheight="0">

<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
FRAMEBORDER="0"></iframe>

</body></html>

it is not auto focuced even with ById
Jul 23 '05 #3
WH wrote:

[iframe focusing]
it is not auto focuced even with ById


You're right, sorry.

Firstly, I've referred you to something not applicable in the first
place; the correct way to focus a frame is to give the frame a name, and
then use
frames["frameName"].focus();

Secondly, I thought that the iframe could be focused, but I cannot
manage to do it in Mozilla, even with the correct way and files from the
same domain. I'm beginning to think this isn't doable, others might give
us more insight.
Regards,
Yep.
Jul 23 '05 #4
"WH" <ke***@whitehouse.gov> writes:
No, notwrking. Test this <body onload="document.getElementById('myframe').focus() ;" leftMargin="0"
rightMargin="0" topMargin="0" marginwidth="0" marginheight="0">

<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
FRAMEBORDER="0"></iframe>


Two points:

The "focus" function exists on window objects, not (i)frame objects.
Using "getElementById" will give you the iframe object, not the window
object inside it. Sadly, there is no standard way to access that window
(some browsers has the non-standard "frameElement.contentWindow",
others only have "frameElement.contentDocument"). To access frames
by name, the best way is to use the frames collection (available as
a global variable, i.e, a property of the window object):
frames['myframe'].focus;

Also, your iframe contains content from another domain. The security
settings might, or might not, prevent you from interacting with the
embedded page's window. Whether it works might depend on whether the
embedded page has begun loading or not, when you access it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5
WH
> Two points:

The "focus" function exists on window objects, not (i)frame objects.
Using "getElementById" will give you the iframe object, not the window
object inside it. Sadly, there is no standard way to access that window
(some browsers has the non-standard "frameElement.contentWindow",
others only have "frameElement.contentDocument"). To access frames
by name, the best way is to use the frames collection (available as
a global variable, i.e, a property of the window object):
frames['myframe'].focus;

Also, your iframe contains content from another domain. The security
settings might, or might not, prevent you from interacting with the
embedded page's window. Whether it works might depend on whether the
embedded page has begun loading or not, when you access it.


IE works every time. Mozzila never works. Here is the code based on
frams.name, still not working.

<html>
<head>
<style type="text/css">
html, body
{
overflow: hidden;
}
</style>

</head>
<body onload="frames.['myframe'].focus();" leftMargin="0" rightMargin="0"
topMargin="0" marginwidth="0" marginheight="0">

<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%
FRAMEBORDER="0"></iframe>

</body></html>
Jul 23 '05 #6
"WH" <ke***@whitehouse.gov> writes:
....
frames['myframe'].focus;
.... IE works every time. Mozzila never works. Here is the code based on
frams.name, still not working. <body onload="frames.['myframe'].focus();" leftMargin="0" rightMargin="0"
I can see it doesn't work. There is a "." too many.
What error message does the browser give you?

Have you validated your HTML?
<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%


I would probably add
name="myframe"
as well, so you have both "id" and "name". It won't hurt, and it might
even work in some older browsers as well.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
WH
> "WH" <ke***@whitehouse.gov> writes:
...
frames['myframe'].focus;
...
IE works every time. Mozzila never works. Here is the code based on
frams.name, still not working.

<body onload="frames.['myframe'].focus();" leftMargin="0"

rightMargin="0"
I can see it doesn't work. There is a "." too many.
What error message does the browser give you?

Have you validated your HTML?
<iframe id="myframe" src="http://www.yahoo.com" width=100% height=100%


I would probably add
name="myframe"
as well, so you have both "id" and "name". It won't hurt, and it might
even work in some older browsers as well.


Thanks. It is working. after I removed . after frames and added name=
However it is not working in Opera yet. Opera 7.2
Jul 23 '05 #8

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

Similar topics

6
by: Geoff | last post by:
When trying to focus a field in Firefox, I get the following error: Error: " nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::...
7
by: Stefan Mueller | last post by:
I choose 'Entry 4' and click then on the button 'Set' to set the index to 'Entry 2'. If you press now the cursor down key 'Entry 5' instead of 'Entry 3' shows up with Mozilla Firefox. With Internet...
4
by: Csaba Gabor | last post by:
Up until a few weeks ago, javascript code like window.open("http://mydomain.com", "windowName"); would always bring my new or reused window to the top, with focus. Lately, Firefox (Deer park...
3
by: Joey | last post by:
I have a javascript piece that sets focus to a textbox on one of my webforms. The script works fine for IE: it sets the cursor blinking in the textbox. In Firefox, however, it doesn't work at all....
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
1
by: Stefan Mueller | last post by:
In my example the focus should only jump to textbox2 if you press the tab key and if '11' is in textbox1. That works fine. However if you enter e.g. '12' in textbox1 and click on 'Link', Mozilla...
5
by: linuxnooby | last post by:
This is a simple question but it is doing my head in all i want is a form text field to be focused when the page loads. Works in IE6 but not in Firefox 1.6 <body > <form...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
3
by: acehigh1983 | last post by:
Is it possible to focus a window in firefox and safari?? i have a webpage that opens another window, it then focuses on the original window (the new window that opened now behind it in the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.