IE is randomly minimizing when a link is clicked

风流意气都作罢 提交于 2019-12-01 01:08:00

问题


I have the bizarre problem. When I click on a link in IE7 the window minimizes. It seems to only be a subset of the links on the page. It also doesn't consistently happen with the same link and differs from computer to computer.

example link text:
<a hidefocus="on" href="#" tabindex="1"><span unselectable="on" id="extdd-102">Canadian Legislation</span></a>

Anyone seen this before or have any idea what might be causing it?


回答1:


Finally figured it out. It was actually a custom JavaScript click handler that caused the problem.

My click handler was calling activeElement.blur(); on the current active element (so that events tied to blur fired when the elements were destroyed).

Problem is in IE, if you call blur on anything that isn't an INPUT, it minimizes the window.




回答2:


I had the same issue on Internet Explorer 10.

  • Internet Explorer 10 tested behaviour:

This issue only happen when you invoke the blur() function on document.body element.

Issue can be reproduced simply executing

 document.body.blur() 
in your browser console.
  • Common scenario in which this issue happens:

document.activeElement.blur() function invocation is the most common scenario in which this issue occurs because after first invocation of document.activeElement.blur() the body element will become the activeElement and subsequent call to document.activeElement.blur() will invoke blur on body element.

  • Solution:

avoid document.body.blur() function invocation, if you have jquery you can introduce this simple logic

 $(yourObj).is('body') 

to check if your object is the body element, in order to avoid blur() function invocation on it




回答3:


IE is buggy, so you can troubleshoot by removing "tabindex". If that doesn't work try removing "unelectable" then "hideonfocus". "Hideonfocus" sounds weird. Try removing that first. Do you have any third party programs or plugins that interact with IE? Does it work on a different computer?




回答4:


This happened when I used the blur workaround to get the placeholder attribute to work on IE8. In the workaround I should call blur() which caused the browser to blur (minimize to tray). The solution is to use:

$.each($('[placeholder]'), function(i,item){ item.blur();});

which is only being specific what to call blur on.

The complete placeholder workaround is:

$('[placeholder]').focus(function() {
    var input = $(this);
    if (input.val() === input.attr('placeholder')) {
        input.val('');
        input.removeClass('placeholder');
    }
}).blur(function() {
    var input = $(this);
    if (input.val() === '' || input.val() == input.attr('placeholder')) {
        input.addClass('placeholder');
        input.val(input.attr('placeholder'));
    }
}).blur();

$(window).on('load', function () {
    if ( $('[placeholder]').length ){
    $.each($('[placeholder]'), function(i, item){item.blur();});
    }
});


来源:https://stackoverflow.com/questions/3586139/ie-is-randomly-minimizing-when-a-link-is-clicked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!