Question

I am building a light weight forum. I can show user's activity; e.g. their recent topics and comments. I would like to be able to link from their recent comments to the specific comment on the forum. Does anyone know a way to do this through mvc or jquery?

Thanks, Guido

Was it helpful?

Solution

You can do this using plain HTML...

On the actual comment on the forum, add a anchor tag with the comment ID as the name.

<div>
    <a href="12345"></a>Some comments...
</div>

Then on the recent comments page, add the comment ID as a hash on the URL to the forum post...

<a href="/forum/posts/somepost#12345">Comment on post "somepost"</a>

This will tell the browser to scroll to the named anchor by that name. If you want, you can use some JavaScript or jQuery to light up the comment (like they do here at StackOverflow). You can access the hash in the URL from JavaScript using window.location.hash.

Here's a working example courtesy of StackOverflow... MVC Forum; Jump to a specific answer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top