开发者

Can I modify elements in iframes from the parent page?

I have a page containing two separate iframes(header and navigation), which have some links inside. (I know it sucks. I have to do this, because the header and navigation are actually from another project)

When I click the links inside the iframes, only the relevant iframe changes. While what I want is that when I click the link, the whole page, namely the current window, changes to that new URL.

I 开发者_开发技巧know javascript injection is not possible and I can't append a <base target='_top'> into iframes' <head>.

Is there any way I can achieve what I want? Or if you have a better way other than <iframe>, please don't hesitate to tell me. I'm still a novice in Front-End engineering. Any help will be appreciated.


Add target="_top" to the links in the frames, e.g.

<a href="SomePage.aspx" target="_top">Click me</a>


Same domain? Go to town and inject a tag, or modify all of the a tags to have a target. I can add more info on how to do it if needed.

Edit Here's a jsbin page for completeness: http://jsbin.com/osoji4/10

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜