Created
May 6, 2017 10:44
-
-
Save hail2u/50b54a682aa5bb69eef065f650f17909 to your computer and use it in GitHub Desktop.
検索フォームへフォーカスするために苦労するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* site-search-focus.js | |
* | |
* LICENSE: http://hail2u.mit-license.org/2017 | |
*/ | |
"use strict"; | |
function focusSiteSearch() { | |
document.getElementById("site_search").focus(); | |
} | |
function checkHash() { | |
if (location.hash === "#site_search") { | |
focusSiteSearch(); | |
} | |
} | |
document.getElementById("site_search_icon").addEventListener("click", focusSiteSearch, false); | |
window.addEventListener("hashchange", checkHash, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment