单击链接时 IE 会随机最小化

发布于 2024-09-16 06:48:29 字数 245 浏览 10 评论 0原文

我有一个奇怪的问题。当我单击 IE7 中的链接时,窗口最小化。它似乎只是页面上链接的子集。它也不会始终在相同的链接上发生,并且因计算机而异。

链接文本示例:
加拿大立法 ;

有人以前见过这个或者知道可能是什么原因造成的吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情话难免假 2024-09-23 06:48:29

终于想通了。实际上,一个自定义 JavaScript 点击处理程序导致了该问题

我的点击处理程序正在对当前活动元素调用 activeElement.blur(); (以便在元素被销毁时触发与模糊相关的事件)。

问题在于 IE 中,如果您对任何不是输入的内容调用模糊,它会最小化窗口。

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.

遗失的美好 2024-09-23 06:48:29

我在 Internet Explorer 10 上遇到了同样的问题。Internet

  • Explorer 10 测试行为:

仅当您在 document.body 元素上调用 Blur() 函数时才会发生此问题。

只需执行即可重现问题

 document.body.blur() 

in your browser console.

  • 发生此问题的常见场景:

document.activeElement.blur() 函数调用是发生此问题的最常见场景,因为首次调用 document.activeElement.blur() 后,body 元素将成为 activeElement 并随后调用document.activeElement.blur() 将在 body 元素上调用模糊。

  • 解决方案:

避免调用 document.body.blur() 函数,如果你有 jquery,你可以引入这个简单的逻辑

 $(yourObj).is('body') 

来检查你的对象是否是 body 元素,以避免对其调用 Blur() 函数

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

徒留西风 2024-09-23 06:48:29

IE 有问题,因此您可以通过删除“tabindex”来排除故障。如果这不起作用,请尝试删除“unelecable”,然后删除“hideonfocus”。 “Hideonfocus”听起来很奇怪。先尝试删除它。您有与 IE 交互的第三方程序或插件吗?它可以在不同的计算机上运行吗?

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?

无悔心 2024-09-23 06:48:29

当我使用模糊解决方法让占位符属性在 IE8 上工作时,就会发生这种情况。
在解决方法中,我应该调用blur(),这会导致浏览器模糊(最小化到托盘)。
解决方案是使用:

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

这只是具体说明什么是模糊。

完整的占位符解决方法是:

$('[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();});
    }
});

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();});
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文