aboutsummaryrefslogtreecommitdiffstats
path: root/linkHints.js
diff options
context:
space:
mode:
Diffstat (limited to 'linkHints.js')
-rw-r--r--linkHints.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/linkHints.js b/linkHints.js
index 9831f3fe..047cbcae 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -161,8 +161,9 @@ function updateLinkHints() {
deactivateLinkHintsMode();
else if (linksMatched.length == 1) {
var matchedLink = linksMatched[0];
- if (isInputOrText(matchedLink)) {
+ if (isSelectable(matchedLink)) {
matchedLink.focus();
+ // When focusing a textbox, put the selection caret at the end of the textbox's contents.
matchedLink.setSelectionRange(matchedLink.value.length, matchedLink.value.length);
} else {
// When we're opening the link in the current tab, don't navigate to the selected link immediately;
@@ -178,6 +179,15 @@ function updateLinkHints() {
}
/*
+ * Selectable means the element has a text caret; this is not the same as "focusable".
+ */
+function isSelectable(element) {
+ var selectableTypes = ["search", "text", "password"];
+ return (element.tagName == "INPUT" && selectableTypes.indexOf(element.type) >= 0) ||
+ element.tagName == "TEXTAREA";
+}
+
+/*
* Hides link hints which do not match the given search string. To allow the backspace key to work, this
* will also show link hints which do match but were previously hidden.
*/