how to jump to #unread anchor

Post a reply

This question is a means of preventing automated form submissions by spambots.
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: how to jump to #unread anchor

Re: how to jump to #unread anchor

by axew3 » Sat Nov 28, 2020 10:15 am

It scroll to last post, but should instead scroll to, the last unread post, which could be not the last one inserted on thread, when there are more new replies? Do not know how it work, not checked deeply in true, so i will check asap how phpBB execute this task, and how to mimic it.

P.s i see it exist a template S_LOAD_UNREADS var which
so i assume it is the easy and correct way to accomplish with this

mh... just checked, no it is not the way ... let see asap more deeply

and on fly, i see that could be possible checking for class unreadpost, so the above code need to be little changed to achieve correctly the result

Re: how to jump to #unread anchor

by zawin » Sat Nov 28, 2020 10:08 am

I found problem with this code - If I click to URL with #unread anchor, then page jumps to the latest post instead of the latest unread post.

Re: how to jump to #unread anchor

by zawin » Tue Nov 24, 2020 7:23 am

I can confirm that code works. I changed selector based on my page structure. Thank you ;)

Re: how to jump to #unread anchor

by axew3 » Sat Nov 21, 2020 12:30 am

The V5 overall_footer.html code has been updated to resolve this issue: ... iframe-v5/

To fix:

on added overall_footer.html js code, find this line:

Code: Select all

var hash = window.location.hash.substr(1);
immediately after, add this:

Code: Select all

if( hash == 'unread' ){
 	var postN = 1;
 $( "h3 > a" ).each(function (e) { // need to match on DOM
   ns = this.href.split('#p'); 
   if( typeof ns != 'undefined' && /viewtopic.php\?p=/ig.exec(this.href) != null ){
   	if(ns[1] > postN){
	   w3lh = ns[1];
 if( typeof w3lh != 'undefined' ){
  hash = "p" + w3lh;

remember to recompile phpBB template.

Note that the code search for h3 elements, containing a elements, than containing strings like this viewtopic.php?p=
so on theme DOM, the posts titles links, needs to exists wrapped like they are into default subsilver, or this line:
$( "h3 > a" ).each(function (e) {
need to change selectors to match on DOM correct post's a links.

Work fine into all themes where post's links a elements are inside an h3 element, like it is on prosilver, but into all themes?
In case as said, the line of code that search for elements on DOM need to be changed to match.
Do not know if there is another way than this to achieve and resolve. I do not think that there is, at moment.

Re: how to jump to #unread anchor

by axew3 » Thu Nov 19, 2020 11:10 am

yes, you read on my mind thank you for report, known problem.
FIXED V6 will fix this, and any redirected link like these (as well any other):

Code: Select all
added on queue into this thread ... f=2&t=1585
where V5 code has been also reported to be patched to fix something else in the while.
I will check to fix on fly if i can find out a moment, even before V6

how to jump to #unread anchor

by zawin » Thu Nov 19, 2020 9:33 am

in received email it is following link, which points to the last unread post: /Forum/viewtopic.php?f=5&t=1&e=1&view=unread#unread
It is possible to jump to the anchor #unread, after page with this link is loaded?

Thank you.