W3C home > Mailing lists > Public > public-sdw-wg@w3.org > February 2017

Document not loaded to right fragment (was: ssn -- and use case work to be done request for help)

From: Francois Daoust <fd@w3.org>
Date: Tue, 21 Feb 2017 23:29:00 +0100
To: Kerry Taylor <kerry.taylor@anu.edu.au>, SDW WG Public List <public-sdw-wg@w3.org>
Cc: "Kolozali, Sefki" <sefki.kolozali@kcl.ac.uk>
Message-ID: <d9074d06-1c31-95e9-c2a5-b54837a725f0@w3.org>
Hi Kerry,

Le 05/02/2017 à 11:58, Kerry Taylor a écrit :
[...]
> @Francois – while looking at this I can see the fragment part of the
> urls into the UCR document do not get to the right place in the
> document. We are used to them not working on github instances – but
> shouldn’t it work on these docs in TR space?

Well, they should!

>  You can use this as an
> example. https://www.w3.org/TR/sdw-ucr/#CRSDefinition Whether it works
> or not seems to depend on something in browser state (as it seems to be
> ok once navigating within the page).  Or am I doing something wrong? But
> it does seem  to work as I’d expect on at least some other TR space
> documents.

The only thing different between this document and other TR documents is 
the JavaScript code that runs when the document is loaded to collapse 
sections.

That script indeed seems to bug Firefox when the document is loaded for 
the first time. It seems to bug Edge once in a while as well. And it 
does not seem to bother Chrome at all. I guess the result depends on 
whether it runs after or before the browser scrolls down to the fragment 
position... One workaround that seems to work is to add the following 
near the end of the "init" function to force the browser to re-apply the 
hash:

  document.location.hash = document.location.hash;

There may be a cleaner way to do this though. I'll investigate.

For what it's worth, quickly looking at the HTML spec, I would say that 
browsers are free to do whatever they want here: the "update the session 
history with the new page" [1] algorithm allows browsers to "Spin the 
event loop for a user-agent-defined amount of time" before they "Scroll 
to the fragment identifier".

Side note: refreshing a page with a fragment in most browsers won't 
focus on the fragment again if you scrolled down to another part of the 
document. I believe that is intended not to lose the current position.

Francois.

[1] 
https://www.w3.org/TR/html51/browsers.html#updating-the-session-history-with-the-new-page
Received on Tuesday, 21 February 2017 22:29:16 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:31:30 UTC