B
Bjorn Nordbo
Hello,
I have a page with a vertical list of photos separated with bits of text.
Using page down to view the photos is a bit annoying as it will typically
cut the photos as it only jumps a screenfull at a time.
To work around this I added an anchor just before every photo, so that
the page was organised as follows:
<a name="1" id="1"/>
<img src="foo.jpg"/>
<p>Some text..</p>
<a name="2" id="2"/>
<img src="bar.jpg"/>
<p>Etc..</p>
Then I capture a key, space for instance, and invoke the following
function:
function navigateNext() {
if (!window.location.hash) {
window.location.hash = "#2"
} else {
newItem = parseInt(window.location.hash.substring(1)) + 1
if (document.getElementById(newItem)) {
window.location.hash = "#" + newItem
} else {
window.location.hash = "#1"
}
}
}
This works as a charm, jumping to the next anchor until the end of the
page before starting again. There are two problems, however:
The first (and small one) is that if you have a big monitor you will
fit two pictures in a screenful so that when you hit the end of the
page you will have to press space twice to return to the top.
The second (and much bigger one) is that all this anchor jumping
clutters up the history so that when the user hits the back button
of his browser (and he usually will), he will just jump backwards
through the page. Doh! He would of course expect to get back to
the overview page to browse another series of pictures.
I can't seem to find any solution to these problems, though a back
link might help slightly. Another possibility would be to bounce
the user back to the previous page (the overview) instead of the
start of the page after the last picture.
Good ideas are greatly appreciated!
I have a page with a vertical list of photos separated with bits of text.
Using page down to view the photos is a bit annoying as it will typically
cut the photos as it only jumps a screenfull at a time.
To work around this I added an anchor just before every photo, so that
the page was organised as follows:
<a name="1" id="1"/>
<img src="foo.jpg"/>
<p>Some text..</p>
<a name="2" id="2"/>
<img src="bar.jpg"/>
<p>Etc..</p>
Then I capture a key, space for instance, and invoke the following
function:
function navigateNext() {
if (!window.location.hash) {
window.location.hash = "#2"
} else {
newItem = parseInt(window.location.hash.substring(1)) + 1
if (document.getElementById(newItem)) {
window.location.hash = "#" + newItem
} else {
window.location.hash = "#1"
}
}
}
This works as a charm, jumping to the next anchor until the end of the
page before starting again. There are two problems, however:
The first (and small one) is that if you have a big monitor you will
fit two pictures in a screenful so that when you hit the end of the
page you will have to press space twice to return to the top.
The second (and much bigger one) is that all this anchor jumping
clutters up the history so that when the user hits the back button
of his browser (and he usually will), he will just jump backwards
through the page. Doh! He would of course expect to get back to
the overview page to browse another series of pictures.
I can't seem to find any solution to these problems, though a back
link might help slightly. Another possibility would be to bounce
the user back to the previous page (the overview) instead of the
start of the page after the last picture.
Good ideas are greatly appreciated!