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..983cf38c99cbbe2d7a3f31b723b4acbc26b7d6cf 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 preventPoundLinkClicks() { |
Evan Stade
2012/08/08 20:03:07
I think this function name could be improved becau
Dan Beam
2012/08/08 20:28:11
preventDefaultOnPoundLinkClicks() ?
|
+ document.documentElement.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. |
*/ |