简体   繁体   English

如何在两个框架之间实施“跳至内容”

[英]How to implement 'Skip to Content' between two frames

I am working on a website using frames. 我正在使用框架的网站上工作。 The top frame holds the menu items and the bottom frame holds the main content. 顶部框架保存菜单项,底部框架保存主要内容。

How can I href to main frame content section? 我如何href进入主机内容部分?

In 2017, no one uses frame . 在2017年,没有人使用frame

But if you really want to, you can use the name attribute specified for your bottom frame 但是,如果您确实愿意,可以使用为底框指定的name属性

<frame src="mypage.html" name="bottom" />

in the target attribute of your link: 在链接的target属性中:

<a href="mypage.html" target="bottom">Skip to content</a>

Thanks, for the nostalgia. 谢谢,怀旧。

Using frameset and frame elements is really old-fashioned now. 现在使用framesetframe元素确实是过时的。 (The most prominent examples are probably the Java API documentation , and any other Java documentation generated using Javadoc , and the Eclipse documentation .) However, if you have a frameset containing one frame for navigation and one frame for the main content, here is what you should do. (最著名的示例可能是Java API文档 ,使用Javadoc生成的任何其他Java文档以及Eclipse文档 。)但是,如果您有一个框架集,其中包含用于导航的一帧和用于主要内容的一帧,那么这就是你应该做。

First, give each frame element both a name and a title . 首先,给每个frame元素一个name和一个title The title is for assistive technologies, especially screen readers. title适用于辅助技术,尤其是屏幕阅读器。 See the example below. 请参见下面的示例。

<frameset cols="15%, *">
  <frame src="navigation.html" name="navigation" title="Navigation Bar" />
  <frame src="main.html" name="maincontent" title="Main Content" />
  <noframes>
    <p>Go to the <a href="noframe.html">version without frames</a>.</p>
  </noframes>
</frameset>

Second, make sure the user can navigate between the frames. 其次,确保用户可以在框架之间导航。 Firefox and several other browsers allow the user to navigate to the next frame by pressing F6 and to the previous frame by pressing Shift + F6 , but Google Chrome does not appear to have a keyboard shortcut for this (see Chrome keyboard shortcuts in Google Chrome Help). Firefox和其他几种浏览器允许用户通过按F6导航到下一帧,并通过按Shift + F6导航到上一帧,但是Google Chrome似乎没有为此的键盘快捷方式(请参阅Google Chrome帮助中的Chrome键盘快捷方式) )。 (You would need to add the Vimium extension to have a shortcut for frame nagivation. Frame navigation in Chrome using just a keyboard is a nightmare.) So you would probably need a script that sets the focus to the maincontent frame after clicking a link in the navigation frame. (您可能需要添加Vimium扩展名才能获得框架导航的快捷方式。Chrome仅使用键盘进行框架导航是一场噩梦。)因此,您可能需要一个脚本,该脚本在单击链接后将焦点设置到maincontent框架。 navigation框。 See the question Setting focus to iframe contents for something related. 有关相关内容 ,请参阅将焦点设置为iframe内容的问题。

Alternative solution: stop using frames. 替代解决方案:停止使用框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM