javascript - Hide keystrokes from window-wide listeners -
i'm making extension chrome used on youtube. extension adds overlay on top of video text input. however, typing extension triggers youtube's various keystroke listeners (e.g. space -> pause
). event.stoppropagation()
nothing, neither return false
@ end of angular event callback.
my current (successfully prototyped not yet implemented) solution wrap input in iframe, pass messages parent window:
iframe.contentwindow.document.queryselector("#wrapped-input").addeventlistener("input", function(){ result.innerhtml = this.value; });
i feel solution bit of hack, , i'm hoping find more elegant. aside, using angularjs app, if there angular-specific workarounds, i'd love know too. thoughts?
edit
current solution:
<iframe id="wrapper-frame"></iframe>
...
link: { var input = '<input id="inner-input" />'; var wrap = $window.document.queryselector('#wrapper-iframe').contentwindow.document; $scope.commentinput = wrap.queryselector('#inner-input'); wrap.open(); wrap.write(input); wrap.close(); $scope.commentinput.addeventlistener('input', function(){ var val = this.value; $scope.$applyasync(function(){ $scope.inputcontent = val; }); }); }
it works, still -- iframe. bleh, hack. leave question open in case if has better idea.
Comments
Post a Comment