Link to home
Start Free TrialLog in
Avatar of Relegence
RelegenceFlag for Israel

asked on

Redirect within an Iframe

Hello,

I have an iframe which is located inside a webpage. When i click a button within the iframe which does a redirect to a new url, the new url is displayed on the whole page and not only within the frameset.

I am using: this.document.location.href = url;

How can i make sure the new url would open within the framset only?

Thanks,
Dana
Avatar of kelvinwkw
kelvinwkw
Flag of Malaysia image

Use this
window.location.href  = url ;
the new url will open on the same window by default not unless your new url breaks frame or has a target pointed to "_top".
"your new url breaks frame"  --> "your new url has a script which breaks frame"

btw, do you own the new url page?
Avatar of Relegence

ASKER

I am sorry, I just realized that the problem is slightly different:
The Iframe is located at the bottom of the parent page. When redirecting, the focus of the parent page is set to the iframe so that it looks at the top. But, if you scroll up you can see the rest of the parent page.
How can i redirect and live the focus at the same position?
Thank you
or you may try this

document.getElementById(yourIFrameID).src = url;
I don't own the parent page.
The parent page which holds the Iframe is managed by someone else whom i gave the url to the iframe.
The iframe contains buttons that cause redirect to the same Iframe.

The question is why after redirect the focus of the parent page is moved to the iframe?
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just what i needed. Thanks!!!