diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-07 11:08:35 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-07 11:08:35 +0100 |
commit | 84bf0b24e0a6b584311218108ca953f911901c74 (patch) | |
tree | d8fe156ce0c3a5cc04b89b6a53b39e9383c3167b | |
parent | 0e2ef2aa2495fa19d7cc7a25cceef58c572494ca (diff) |
fix IE bug input event bug
The IE 'input' event doesn't work propery. Use non-standard 'textinput' event on IE instaid.
-rw-r--r-- | public/javascripts/main.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 722031d..4ebc6c8 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -88,7 +88,15 @@ searchNode.addEventListener('keydown', function (e) { } }) -searchNode.addEventListener('input', function (e) { +let inputEventStr +if (navigator.userAgent.indexOf('MSIE') !== -1 || + navigator.appVersion.indexOf('Trident/') > 0) { + inputEventStr = 'textinput' // IE 6-11 +} else { + inputEventStr = 'input' // normal browsers +} + +searchNode.addEventListener(inputEventStr, function (e) { document.body.className = '' autocompleteNode.innerHTML = '' if (inputNode.value.trim() === '') return |