468,791 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

iframes and parent window

I have an IFRAME on a webpage with a large height to accommodate a big
list output in the frame.

If I go down the list and click a row, a new page opens in the IFRAME,
but this is a problem if the list is long since the user must then
manually scroll up to the top of the parent page to see the new page.

Is it possible to scroll the parent window to the top using javascript
whenever the page in the IFRAME changes?

Thanks!
--

"I hear ma train a comin'
.... hear freedom comin"
Jul 23 '05 #1
9 15649
Stimp wrote:
I have an IFRAME on a webpage with a large height to accommodate a big list output in the frame.

If I go down the list and click a row, a new page opens in the IFRAME, but this is a problem if the list is long since the user must then
manually scroll up to the top of the parent page to see the new page.

Is it possible to scroll the parent window to the top using javascript whenever the page in the IFRAME changes?

Thanks!
--

"I hear ma train a comin'
... hear freedom comin"


Might try...

<script type="text/javascript">

if (parent) parent.location.hash = '#';

</script>

(in the iframe document)

Jul 23 '05 #2
On Fri, 11 Feb 2005 RobB <fe******@hotmail.com> wrote:
Stimp wrote:

Might try...

<script type="text/javascript">

if (parent) parent.location.hash = '#';

</script>

(in the iframe document)


I tried something like that, putting the function in the <body
onload> call, but I got a 'permission denied' javascript error.

The page is .asp, so I wonder does that have any affect on the
permissions between parent and iframe content?
--

"I hear ma train a comin'
.... hear freedom comin"
Jul 23 '05 #3
rf
"Stimp" <re*@spumco.com> wrote

[iframed page]

I tried something like that, putting the function in the <body
onload> call, but I got a 'permission denied' javascript error. The page is .asp, so I wonder does that have any affect on the
permissions between parent and iframe content?


No it does not. The browser knows nothing about asp or any other form of
server side sripting for that matter.

You are trying to use javascript across different domains (I assume your
iframed page is from a different domain to your main page). This is not
allowed for security reasons.

--
Cheers
Richard.
Jul 23 '05 #4
On Sat, 12 Feb 2005 rf <rf@.> wrote:
"Stimp" <re*@spumco.com> wrote

[iframed page]

I tried something like that, putting the function in the <body
onload> call, but I got a 'permission denied' javascript error.

The page is .asp, so I wonder does that have any affect on the
permissions between parent and iframe content?


No it does not. The browser knows nothing about asp or any other form of
server side sripting for that matter.

You are trying to use javascript across different domains (I assume your
iframed page is from a different domain to your main page). This is not
allowed for security reasons.


aye that would be it... essentially we are creating a system for
affiliates to our web site where they can include the iframe on their
own site (different domain obviously) and the iframe will process pages
from our domain.

This is only a temporary measure.. ideally we would store the affiliate
pages on our own server and the affiliate could upload their own header
and footer for the page.

Assuming that we can add javascript to both the affiliate's page and the
iframe content, is there an alternative approach I should look at for
the problem of scrolling the main page to the top when the iframe
changes?

I don't suppose there's something like:

onIframeChange='parent.scroll(0,0)'

to detect when the iframe content refreshes?
--

"I hear ma train a comin'
.... hear freedom comin"
Jul 23 '05 #5
rf
"Stimp" <re*@spumco.com> wrote
On Sat, 12 Feb 2005 rf <rf@.> wrote:
"Stimp" <re*@spumco.com> wrote

[iframed page] You are trying to use javascript across different domains (I assume your
iframed page is from a different domain to your main page). This is not
allowed for security reasons.
aye that would be it... essentially we are creating a system for
affiliates to our web site where they can include the iframe on their
own site (different domain obviously) and the iframe will process pages
from our domain.


Thought so. Accept that this will not work then.
This is only a temporary measure.. ideally we would store the affiliate
pages on our own server and the affiliate could upload their own header
and footer for the page.
Better. In the same domain you can do whatever you want.
Assuming that we can add javascript to both the affiliate's page and the
And how would the affiliate feel about you adding stuff to their page? I for
one would no longer be an "affiliate".
I don't suppose there's something like:

onIframeChange='parent.scroll(0,0)'

to detect when the iframe content refreshes?


Sorry, no comment. I don't use iframes and I abhore their use by other
authors, just like I dont use and abhore frames in general.

HTH
--
Cheers
Richard.
Jul 23 '05 #6
> Sorry, no comment. I don't use iframes and I
abhore their use by other
authors, just like I dont use and abhore frames
in general.


Don't abhor frames in general. They do have their use depending on what
you're doing.

For example, I created a live chat application using javascript. It could
never have been possible without iframes.

On the question of auto scrolling a page to the top, crossdomain scripting
is just not allowed in javascript. The only way I know of is to have your
affiliates add the necessary code themselves.

Jul 23 '05 #7
On Sun, 13 Feb 2005 phpcode <qu*******@oasisoflove.com> wrote:
Sorry, no comment. I don't use iframes and I
abhore their use by other
authors, just like I dont use and abhore frames
in general.


Don't abhor frames in general. They do have their use depending on what
you're doing.

For example, I created a live chat application using javascript. It could
never have been possible without iframes.

On the question of auto scrolling a page to the top, crossdomain scripting
is just not allowed in javascript. The only way I know of is to have your
affiliates add the necessary code themselves.


Assuming that they add the code themselves, what code would they need to
add?

Cheers.
--

"I hear ma train a comin'
.... hear freedom comin"
Jul 23 '05 #8

I too am interested in this. I control two domains and can freely add
javascript to both pages. Is there a way for the iframe to tell the
parent what its height and width are? I understand the security issue,
but shouldn't there be a way form people who obviously own both domains
(ie javascript in iframe and parent)?

Thank you for your time,
David
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #9


I figured this out. In my case, you must put

document.domain="somedomain.com";
this will allow you to use subdomains and different ports. It will
not, however, let you use completely differnt domains.
---david

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by bscofield | last post: by
1 post views Thread by Tom Szabo | last post: by
6 posts views Thread by adnanx82 | last post: by
8 posts views Thread by Ashish | last post: by
CroCrew
2 posts views Thread by CroCrew | 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.