go to a specific id on parent frame

R

Rasmussen

Instead of: window.parent.frames["main"].location.reload;

I would like to go to the top / bottom of the parent frame, but how?
with no reload.
 
P

Peter Michaux

Instead of: window.parent.frames["main"].location.reload;

I would like to go to the top / bottom of the parent frame, but how?
with no reload.

Do you mean "scroll to"?

Peter
 
R

Rasmussen


I found out this:

function scrUp() {
window.parent.frames("main").scrollTo(0,0)
}

But I have: <base target = "main">

And it does not work with that.
 
D

David Mark

I found out this:

function scrUp() {
window.parent.frames("main").scrollTo(0,0)

The frames object not a function. You had the syntax right in your
original post.
}

But I have: <base target = "main">

And it does not work with that.

What does one have to do with the other?
 
R

Rasmussen

The frames object not a function. You had the syntax right in your
original post.


Ok, this works:
function scrUp() {
window.parent.frames("main").scrollTo(0,0)
}
function scrDw() {
window.parent.frames("main").scrollTo(0,8888)
}
What does one have to do with the other?

It works from the "menu" frame, and there are several links to "main"
But I removed <base target = "main">
so it works ok now.

Could the code be better/different?
 
D

David Mark

Ok, this works:
function scrUp() {
window.parent.frames("main").scrollTo(0,0)
}
function scrDw() {
window.parent.frames("main").scrollTo(0,8888)
}

No it doesn't. I repeat: the frames object is not a function.
Firefox will tell you this in the error log. IE is stupid.
It works from the "menu" frame, and there are several links to "main"
But I removed <base target = "main">
so it works ok now.

I still don't see what the base target has to do with this script.
Could the code be better/different?

Yes. You could use proper brackets (eg square ones) to reference
properties of the frames object.
 
A

ASM

En réponse à Rasmussen qui nous a susurré, en date du : 29/07/07 23:42,
le message sibyllin suivant :
But unfortunately not with FF :-(


of corse ! with ("main") insteed of ["main"] ... !

function scrUp() {
window.parent.frames["main"].scrollTo(0,0);
return false;
}
function scrDw() {
window.parent.frames["main"].scrollTo(0,8888);
return false;
}



The menu frame file :

<html>
<base target="main">
<div id="udDown">
<p><a href="#" onclick="return scrUp();">top</a>
<p><a href="#" onclick="return scrDw();">bottom</a>
</div>
<div id="menu">
<p><a href="page1.htm">page 1</a>
<p><a href="page2.htm">page 2</a>
<p><a href="page3.htm">page 3</a>
</div>
</html>
 
R

Richard Cornford

David said:
On Jul 29, 5:34 pm, Rasmussen <> wrote:

No it doesn't. I repeat: the frames object is not a function.
Firefox will tell you this in the error log. IE is stupid.
<snip>

In javascript a function is an object and so the object that is the -
frames - collection (or any collection) may be a function. On IE, Opera
and (as I recall) Safari (along with others) they are functions (and
some will even say 'function' as a result of - (typeof frames) -).
Calling a collection with name as the argument is never going to be
cross-browser because some collections are not functions, but there is
nothing to say they may not be.

Richard.
 
D

David Mark

<snip>

In javascript a function is an object and so the object that is the -
frames - collection (or any collection) may be a function. On IE, Opera

Opera too. That is odd.
and (as I recall) Safari (along with others) they are functions (and
some will even say 'function' as a result of - (typeof frames) -).

Anyway, the OP was having trouble with FireFox and it is clearly not a
function in FireFox. I'm sure the error log says as much when the OP
runs his code.
 
R

Richard Cornford

David said:
Opera too. That is odd.

Not really. Opera are in a commercial business where imitating the
features of IE is worth-while. They have to accept the fact that there
are web sites out there that are written to be IE only, and to keep
their customers happy they create a browser that can handle (most of)
them.
Anyway, the OP was having trouble with FireFox and it is
clearly not a function in FireFox.

Didn't the OP say his code 'worked'? That mans he is not having trouble
with Firefox, it means he has not tried the code in Friefox (or any
Mozilla/Gecko browser) at all.
I'm sure the error log says as much when the OP
runs his code.

Absolutely it will, though it may be an 'if' rather than a 'when'.

Richard.
 
D

David Mark

Didn't the OP say his code 'worked'? That mans he is not having trouble
with Firefox, it means he has not tried the code in Friefox (or any
Mozilla/Gecko browser) at all.

No. He replied to himself:

so it works ok now.

But unfortunately not with FF :-(
 
R

Rasmussen

On Mon, 30 Jul 2007 00:57:02 +0200, ASM

Error console reports: parent.frames is not a function.
of corse ! with ("main") insteed of ["main"] ... !

Thanx, that did it.

The <base target="main"> does that
\index.html is drawn (one level up > index.html)

Never mind, I put the target on the links.
 
R

Rasmussen

Didn't the OP say his code 'worked'? That mans he is not having trouble
with Firefox, it means he has not tried the code in Friefox (or any
Mozilla/Gecko browser) at all.

At first I did only test with IE6,
ten I found out that it didn't work in FF.

I test with FF, IE6 and Opera.

BTW: It's not poosible to check with AOL browsers (?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top