HTML Anchors? (not Discourse bookmarks)

Hi,

I tried to use HTML to pop some bookmarks into a post today, so that from another link you could get to a specific point in a lengthy post.

I couldn’t seem to get it to work, is this something which isn’t currently supported?

I added this within the post;

<a id="bookmark"></a>

…and then, on the end of the URL in the browser, added;

#bookmark

I hit enter, but nothing changed, e.g. I wasn’t scrolled down to the bookmark automatically. What I am trying to incorporate is the same functionality I suppose as you already use for the replies to a topic (the reply numbers etc), but this would be for say a wiki post which doesn’t have replies, it’s just quite long.

Go to:

your-forum.com/guidelines

Edit, and check how it’s working there :wink:

4 Likes

/facepalm

I didn’t think of that!

Interestingly though, I did try it using the name attribute first and when that didn’t work I used the id instead.

Can you think of any reason why it wouldn’t work if the #bookmark part of the URL was on the end of the topic number?

For example, looking at this topic, I see this in the browser;

https://meta.discourse.org/t/html-bookmarks-not-discourse-bookmarks/77241/2

I appreciate the /2 on the end is for the reply, and the previous number, /77241 is the topic, so, should /77241#bookmark work?


Update

Interesting, taking one the links from the /guidelines page and opening it in a new tab (Chrome) also didn’t exhibit the desired behaviour!

For example;

https://community.gamedev.tv/t/forum-guidelines-faq/5#flag-problems

Only seem to work if they are clicked on, on the actual page…

This was implemented recently – here you go:

Summary: Use headings and make sure the id starts with heading-- and it’ll work :slight_smile:

6 Likes

Thanks for this, is the use of headings mandatory? In my specific case the lengthy page has a number of images on it which I wanted to direct people to specifically, without having to add a heading above each one etc.

I will go and test, but anything further would be appreciated.

I couldn’t get it to work with an <a> element, so I think it must be a heading.

1 Like

Thanks for the info, and yeah, I can’t either… hmm… will have to think on this one as having the text isn’t really what I wanted to do.


Update

/facepalm moment two…

Ok, so I just added an empty heading tag and of course it works perfectly… it does render a little extra “space” where the heading tag would be, but nothing that’s really a problem.

Thanks both - all good now :slight_smile:

2 Likes