469,275 Members | 1,871 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

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 13067
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Geoff | last post: by
4 posts views Thread by Csaba Gabor | last post: by
3 posts views Thread by Joey | last post: by
5 posts views Thread by linuxnooby | last post: by
11 posts views Thread by Alex.Svetos | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.