admin管理员组文章数量:1406943
How can I put an href tag with link to a specific h1 tag in another page? This is what I tried...
<a href="page2.html/subject 2">Move to page 2, section 1</a>
Thanks
How can I put an href tag with link to a specific h1 tag in another page? This is what I tried...
<a href="page2.html/subject 2">Move to page 2, section 1</a>
Thanks
Share Improve this question asked Nov 25, 2017 at 6:28 Dan SDan S 211 silver badge6 bronze badges 1- 2 Possible duplicate of How to navigate to a section of a page – ZerosAndOnes Commented Nov 25, 2017 at 6:33
3 Answers
Reset to default 6You can do something like this:-
<div id="anchor-name"> <h1>Heading goes here </h1></div>
and refer to it later with
<a href="http://server/page.html#anchor-name">Link text</a>
First of all you have to give unique id to h1 tag on page2.
<a href="page2.html/subject 2#firstH1">Move to page 2, section 1</a>
Where #firstH1 is the id given to h1
Add page link to href with additional reference to the id of the specific div containing the heading(h1).
<a href="page2.html#mydiv"> Click to move to next page heading </a>
Here, page2.html is the link to next page and mydiv is the id of the div in which h1 is present.
<div id="mydiv>
<h1> My Heading </h1>
</div>
P.S: You can use the same approach to scroll to different parts on the same page.
Use target='_blank' if you want to open the next page in a new tab.
本文标签: javascriptHtml href to a specific place in another pageStack Overflow
版权声明:本文标题:javascript - Html href to a specific place in another page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745051431a2639679.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论