mslee — 2013-03-18T09:48:30-04:00 — #1
I WOULD LIKE TO KNOW WHEN I CLICK ON THE LINK ON THE BOTTOM OF THE PAGE I WANT THE FOCUS TO STAY AT THE BOTTOM OF THE PAGE AND NOT SHOOT TO THE TOP OF THE PAGE.
IS THIS WRITTEN IN HTML? I HOPE THIS MAKES SENSE ?
dresden_phoenix — 2013-03-18T17:49:58-04:00 — #2
IS THIS WRITTEN IN HTML?
All web pages are written in some sort of HTML variant. So unles syou are not viewing a web page ( and are istead dealing with an app??) the answer is most likely "yes";
What you are asking is not actually possible, off the bat. A HYPERLINK (<a href='some.url'>) directs the focus to a given location ( noted in the href attribute) and not a "scroll position". It wouln't even make sense to do it any other way! So Maybe what you want is not only to link to a specific page but a specific piece of content on a page, that is easy enough to code
On the TARGET PAGES ( the page with the content you want to go to) add an ID to the outermost tag of the desired content, this is often referred to as an ANCHOR
EXAMPLE, in the document page.html:
the deisred content
and when you want the link to go straight to it:
If if the link refers to an anchor on the same document (page) then you don't even need the document name , and you can do this:
I hope that helps
stomme_poes — 2013-03-20T06:37:53-04:00 — #3
I use a similar technique when I'm using an anchor to do a button's job: if the anchor's href is an undefined hash name, the page should not reload and the user should not be brought back up to the top of the page.
<a href="#">CLICK ME</a>
That "#" refers to the current page, and in every browser I know makes a page refresh, which brings focus to the top of the page.
To prevent this, I do something like
<a href="#void">CLICK ME</a>
Void is not a defined id or name attribute anywhere on my page, so #void is an invalid link. Most browsers will hold the focus on that link and not go to another page nor will they refresh the page.
However webkit browsers will not necessarily keep the focus on what was clicked, in contrast to Opera, Firefox and I think IE. They'll hold the focus on the last-clicked thing until the user clicks elsewhere. By focus I mean keyboard focus... visual focus won't change, and the user will stay on the right part of the page visually.
If I'm using an anchor as an in-page destination, and I don't want the user to get thrown to the top of the page if they somehow manage to click the destination, I match the id and the href:
to use Dresden's example but with an anchor for destination instead of a div
Like that. I would only use an anchor as destination though if a focusable destination were required.
jacleaves — 2013-03-20T23:33:02-04:00 — #4
You can also use JQuery ScrollTo to go to a particular position on the page: http://flesler.blogspot.com/2007/10/jqueryscrollto.html
I use it on my website: www.dynamicdzine.com