使用框架链接到外部站点
您好,我想知道是否可以链接到另一个页面的特定框架,并且我仍然希望其他框架可见。
例如:我有一个网站:example.com,我想链接到 anotherexample.com,该网站有一个菜单框架和一个页面框架。
是否可以链接到子页面并且仍然使菜单框架可见?
Hi I'm wondering if it's possible to link to another page's specific frame and I still want the other frames to be visible.
For example: i have a site: example.com and I want to link to anotherexample.com that has one frame for the menu and one for the page.
Is it possible to link to a subpage and still have the menu frame visible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 Frame :
对于 Iframe :使用 Javascript,您可以
var myf = document.getElementById("myiframe");
myf.src = "http://anotherexample.com";
iframe A 必须与父框架位于同一域中才能修改 iframe B src
For Frame :
For Iframe :With Javascript you can
var myf = document.getElementById("myiframe");
myf.src = "http://anotherexample.com";
iframe A must be in the same domain of frame parent to be able to modify iframe B src
这是不可能的。框架内容的组合(“框架集的状态”)没有自己的 URL,这是 HTML 中框架的固有特征,并且经常被视为框架的基本问题。
有一种解决方法可能适用于简单的情况:构建您自己的小型框架集页面,模仿要链接到的网站。使用与链接站点上的相对应的绝对 URL,包括标题、导航和在链接站点上具有相同内容的其他框架。使用服务器端或客户端技术,使您的页面 URL 与包含要在内容框架中显示的特定内容的名称的查询部分配合使用。然后,您将链接到您的这个框架集页面,并根据需要使用不同的查询部分。
这不会处理导航框架中的任何更改(例如将当前页面显示为非链接或突出显示),尽管这可以通过相同行的额外代码来适应。
该解决方法很脆弱(链接站点的更改很容易弄乱它),并且可能会引发版权问题。
It’s not possible. It is an inherent feature of frames in HTML, and often mentioned as a fundamental problem with them, that a combination of frame contents (“state of a frameset”) has no URL of its own.
There’s a workaround that may be applicable in simple cases: construct a small frameset page of your own, imitating the site to be linked to. Include the header, navigation, and other frames that have the same content over the linked site, using absolute URLs that correspond to those on the linked site. Using server-side or client-side technology, make your page URL work with a query part that contains the name of a specific content to be displayed in the content frame. And you would then link to this frameset page of yours, with varying query parts as needed.
This wouldn’t handle any changes in the navigation frame (such as showing the current page as a non-link or as highlighted), though this could be accommodated with extra code along the same lines.
The workaround would be fragile (changes in the linked site can easily mess it up) and might raise copyright issues.