javascript - onblur and link elements not working properly in Chrome - Fine in IE 10 -
i'm trying achieve following. click on link, display menu. menu loses focus, clear menu (also when menu item clicked, remove menu).
here dumbed down code:
<a id="owner" href="javascript: dothis();" onblur="remove();">clickonme</a> function dothis() { console.log('clickedonitem'); } function remove() { console.log('removed'); }
i can't seem work. works fine in ie10, can't work in chrome.
fiddle me this: http://jsfiddle.net/5t6wr/5/
for reason chrome isn't registering link focused item. have force link focused chrome recognizes it.
change link following:
<a id="owner" href="javascript: document.getelementbyid('owner').focus(); dothis();" >clickonme</a>
we added focus owner, proceeded function bring menu.
inside dothis function want add following:
document.activeelement.onblur = function() { remove(); };
that going take current active element - , when focus lost, run script close window.
note: should put remove function on timeout, loading menu, , don't want have both trigger @ same time, cause conflict.
here fiddle see final version: http://jsfiddle.net/5t6wr/4/
Comments
Post a Comment