Jimmy
Jimmy

Reputation: 285

any way of redirecting the whole page from script inside iframe

As the topic says, Im looking for a way to redirect to another page, when i click a link in the iframe. i dont want just the iframe to redirect, but the whole window. is this possible?

preferrably in javascript or in asp.net if possible

EDIT: When i try the answers i get redirected to the source of the iframe, not to the source of the site the iframe lies on... Ill show you the code

            function redirect() {
                window.top.location.href = "./Nyheter.html";
            }

As i dont want the code to be static, so that i can use it on many pages without changing the url, i want to do it this way, alt. get the url from db... but preferrably this way, Solution? Also, forgot to mention. The pages are not on the same domain, they are on different ones.. this could cause some problems.

Upvotes: 2

Views: 12502

Answers (4)

row1
row1

Reputation: 5578

You cannot use the window.top.location if your frame and the top level page are on different domains. A similar answer.

Upvotes: 2

aiham
aiham

Reputation: 3614

You should see this question which is pretty much identical: Redirect parent window from an iframe action

I don't believe you can do it in ASP.net because this has to be done on the client side (ie. Javascript).

window.top.location.href = "http://site.com";

Upvotes: 0

Gatekeeper
Gatekeeper

Reputation: 1616

javascript: window.top.location.href = "xxx"

Upvotes: 0

Andre Backlund
Andre Backlund

Reputation: 6943

<a href="http://google.com" target="_parent">Click me!</a>

Upvotes: 4

Related Questions