Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1322
  • Last Modified:

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
0
Relegence
Asked:
Relegence
  • 3
  • 2
  • 2
  • +1
1 Solution
 
kelvinwkwCommented:
Use this
window.location.href  = url ;
0
 
thirdCommented:
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".
0
 
thirdCommented:
"your new url breaks frame"  --> "your new url has a script which breaks frame"

btw, do you own the new url page?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RelegenceAuthor Commented:
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
0
 
kelvinwkwCommented:
or you may try this

document.getElementById(yourIFrameID).src = url;
0
 
RelegenceAuthor Commented:
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?
0
 
Michel PlungjanIT ExpertCommented:
If you use a link, change it to

<a href="#"
onClick="location.href = url; return false">Click</a>

the return false will stop the parent page from reloading
0
 
RelegenceAuthor Commented:
Just what i needed. Thanks!!!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now