How to code an accesskey to skip to content

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

neilnewman
Ebase User
Posts: 201
Joined: Fri Dec 20, 2013 1:29 pm
Location: Dartford Borough Council
Contact:

How to code an accesskey to skip to content

#1

Postby neilnewman » Mon Jan 23, 2017 2:06 pm

I wish to implement an html accesskey that puts the focus onto the first field within the page.
Is this possible from a generic call.
A typical call using html would be:
<a>Skip to content</a>

NB: I tried adding a "content" div to the html++ part of the Presentation template, but this failed to work.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Jan 24, 2017 9:59 am

You could do this with an HTML control something like this:

Code: Select all

<a href="dummy" accesskey="h" onclick="$&#40;'input&#58;visible&#58;enabled&#58;first'&#41;.focus&#40;&#41;;return false;">skip to top</a>
This uses jQuery. Here's a discussion on different ways to find the first editable field on a page including non-jQuery solutions http://stackoverflow.com/questions/277544

You could probably also achieve this with a Hyperlink Control. To make it generic, put this in a component, then just add the component anywhere that you need it.
0 x

neilnewman
Ebase User
Posts: 201
Joined: Fri Dec 20, 2013 1:29 pm
Location: Dartford Borough Council
Contact:

Thanks Jon that did the job nicely

#3

Postby neilnewman » Wed Jan 25, 2017 2:14 pm

Thanks Jon that did the job nicely
I changed it a bit to read:
onclick="$(':input:enabled:visible:not([readonly]):first').focus();return false;"
which appears to do the job.
0 x


Who is online

Users browsing this forum: No registered users and 33 guests