链接到其他页面上的特定标头 [英] Linking to specific headers on other pages

查看:115
本文介绍了链接到其他页面上的特定标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我设置网站的方式。我有一个名为news.html的页面。此页面的内容只是一个固定大小的iframe。 iframe链接到innernews.html,这是我试图显示的实际内容。我通过这种方式设置它以保持每个页面的大小一致。 iframe可防止页面高度因额外内容而扩展,并且可滚动。

Here's the way I've set-up my site. I have a page called "news.html". The content of this page is just an iframe with a fixed size. The iframe links to "innernews.html", which is the actual content I'm trying to display. I have it set-up this way to keep every page consistently sized. The iframe prevents the height of the page from expanding due to extra content, and is scrollable.

如何在innernews.html页面中创建针对特定元素/标题的链接?如果没有办法实现这一点,我将删除iframe并将内容直接插入news.html。但我仍然不知道如何创建一个针对特定元素/标题的链接...

How would I create a link targeting a specific element/header within my "innernews.html" page? If there isn't a way to achieve this, I'll remove the iframe and just plug content straight into "news.html". But still I wouldn't know how to create a link that targets a specific element/header...

推荐答案

你可以链接仅当元素具有 id 属性或者 a 具有名称属性的元素。在这两种情况下,将片段标识符 #foo 放在链接中URL的末尾,其中 foo 是属性的值。

You can link to an element (on another page or on the same page) only if the element has the id attribute or it is an a element with the name attribute. In both cases, put the fragment identifier #foo at the end of the URL in the link, where foo is the value of the attribute.

如果链接到的页面不包含这样的属性,并且它不在您的控制范围内,那么您将失去运气

If the page being linked to does not contain such an attribute, and if it is outside your control, you are out of luck

这篇关于链接到其他页面上的特定标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆