Index: chrome/browser/resources/shared/js/util.js |
diff --git a/chrome/browser/resources/shared/js/util.js b/chrome/browser/resources/shared/js/util.js |
index 729d7d5da017e2b485139ad7f008d93a4e6e1fc7..7c1b5c288aa1abd8f98004ff87fac060e7ee2449 100644 |
--- a/chrome/browser/resources/shared/js/util.js |
+++ b/chrome/browser/resources/shared/js/util.js |
@@ -129,6 +129,17 @@ function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) { |
} |
/** |
+ * Call this to stop clicks on <a href="#"> links from scrolling to the top of |
+ * the page (and possibly showing a # in the link). |
+ */ |
+function preventDefaultOnPoundLinkClicks() { |
+ document.addEventListener('click', function(e) { |
+ if (e.target.nodeName == 'A' && e.target.getAttribute('href') == '#') |
+ e.preventDefault(); |
+ }); |
+} |
+ |
+/** |
* Check the directionality of the page. |
* @return {boolean} True if Chrome is running an RTL UI. |
*/ |