Note: This post is *not* about static bookmarks (id="ref" and '#ref').
I'd like to dynamically create a bookmark in a HTML page. Upon close
and re-open of that page that bookmark location should be restored.
The latter requires using (for example) cookies to store that info.
But what is the best method to identify some place in the document
and later use that information to address that place again?
Actually, all I want is a digital equivalent of a physical bookmark
in a real book; to continue reading of the book (the HTML document)
another time.
I want to use just plain HTML, CSS, JS. (No libraries/frameworks.)
One way to _maybe_ make that possible is to count the HTML elements
up to the current, say, clicked location. But that appears not very
elegant to me - ...if it's feasible at all in the first place.
Any ideas?
Janis
On Mon, 29 Jul 2024 15:43:57 +0200, Janis Papanagnou wrote:
Note: This post is *not* about static bookmarks (id="ref" and '#ref').
I'd like to dynamically create a bookmark in a HTML page. Upon close
and re-open of that page that bookmark location should be restored.
The latter requires using (for example) cookies to store that info.
But what is the best method to identify some place in the document
and later use that information to address that place again?
Actually, all I want is a digital equivalent of a physical bookmark
in a real book; to continue reading of the book (the HTML document)
another time.
I want to use just plain HTML, CSS, JS. (No libraries/frameworks.)
One way to _maybe_ make that possible is to count the HTML elements
up to the current, say, clicked location. But that appears not very
elegant to me - ...if it's feasible at all in the first place.
Any ideas?
An URL has no capability to point to a specific page scroll position. So if an URL is required, the closest thing is to point the URL to the page which was last viewed.
On 30.07.2024 05:07, JJ wrote:
On Mon, 29 Jul 2024 15:43:57 +0200, Janis Papanagnou wrote:
Note: This post is *not* about static bookmarks (id="ref" and '#ref').
I'd like to dynamically create a bookmark in a HTML page. Upon close
and re-open of that page that bookmark location should be restored.
The latter requires using (for example) cookies to store that info.
But what is the best method to identify some place in the document
and later use that information to address that place again?
Actually, all I want is a digital equivalent of a physical bookmark
in a real book; to continue reading of the book (the HTML document)
another time.
I want to use just plain HTML, CSS, JS. (No libraries/frameworks.)
One way to _maybe_ make that possible is to count the HTML elements
up to the current, say, clicked location. But that appears not very
elegant to me - ...if it's feasible at all in the first place.
Any ideas?
An URL has no capability to point to a specific page scroll position. So if >> an URL is required, the closest thing is to point the URL to the page which >> was last viewed.
Sorry if I was unclear; let me try to clarify...
I don't want that position being coded in the URL (but see below
for an idea with id=BM and the URL containing #BM), I think I'll
at least have to store (and later restore) that position in/from
a cookie to keep that bookmark user-defined.
There's just one (but long) HTML page representing a book with
chapters and paragraphs. Any URL used is thus just the single
one that is pointing to that one HTML page.
With the help of chapter IDs I can jump to the (fixed) chapters
on the HTML page.
Within a chapter I want to define a dynamic mark (a "bookmark";
but not in the sense of a browser's bookmark where AFAICT only
whole HTML pages are subject to being bookmarked). I want <p>
entities on that single HTML page bookmarked. (But ideally not
by setting an 'id' attribute to every existing paragraph.)
With help of JS it should be possible to get some location in
the DOM, for example corresponding to the entity clicked on.
With such information I could for example modify a <p> DOM
entity on page-load with an 'id="BM"' and initate a reload
with that mark set 'http...#BM' to get that position loaded.
This is where I'm looking for some concrete hints. - Thanks.
BTW: Browsers seem to be able to restore the previous scroll
position (e.g. when pages are restrored after a crash).
Janis
PS: But maybe a JS group is better suited to address that Q ?
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 62:44:55 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,046 |