大佬教程收集整理的这篇文章主要介绍了html5 – 在Internet Explorer中使用自动对焦时,模态中的奇怪光标位置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
幸运的是,我已经能够在plunker中重现这一点.我已经将它剥离到了基本要素,所以它应该很容易看到发生了什么.
我如何使IE表现?
AngularJS(也可在plunker中获得)
app.directive('autofocus',[ '$timeout',function($timeout) { return function(scope,elem,attr) { scope.$on('autofocus',function(E) { $timeout(function() { elem[0].focus(); }); }); }; } ]); /* https://stackoverflow.com/questions/14833326/how-to-set-focus-in-angularjs */ app.factory('autofocus',['$rootScope','$timeout',function($rootScope,$timeout) { return function() { $timeout(function() { $rootScope.$broadcast('autofocus'); }); }; }]); app.config(['$stateProvider',function ($stateProvider) { $stateProvider.state('main',{ url: '/main' }); }]); app.config(['$stateProvider',function ($stateProvider) { $stateProvider.state('main.modal',{ url: '/modal',onEnter: ['$state','$stateParams','$modal','autofocus',function ($state,$stateParams,$modal,autofocus) { var instance = $modal.open({ templateUrl: 'modal.html' }); instance.result.then(function () { // OK // GOTO parent state $state.go('^'); },function () { // Cancel // GOTO parent state $state.go('^'); }); instance.opened.then(function() { autofocus(); }); } ] }); }]);
<form> <div class="modal-header"> <h3 class="modal-title">I'm a modal!</h3> </div> <div class="modal-body"> <input type="text" name="foo" autofocus> <br> <input type="text" name="bar"> </div> <div class="modal-footer"> <button type="submit" class="btn btn-priMary">OK</button> <button type="button" class="btn btn-warning" ng-click="$dismiss()">Cancel</button> </div> </form>
app.config(['$stateProvider',autofocus) { var instance = $modal.open({ templateUrl: 'modal.html',windowClass: 'modal fade in' }); instance.result.then(function () { // OK // GOTO parent state $state.go('^'); },function () { // Cancel // GOTO parent state $state.go('^'); }); instance.opened.then(function() { autofocus(); }); } ] }); }]);
以上是大佬教程为你收集整理的html5 – 在Internet Explorer中使用自动对焦时,模态中的奇怪光标位置全部内容,希望文章能够帮你解决html5 – 在Internet Explorer中使用自动对焦时,模态中的奇怪光标位置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。