动态加载jQuery mobile会导致IE最小化 [英] Dynamically loading jQuery mobile causes IE to minimize

查看:103
本文介绍了动态加载jQuery mobile会导致IE最小化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是迄今为止我遇到过的最奇怪的错误。这很简单。如果我在任何版本的Internet Explorer中加载jQuery,然后加载jQuery mobile,则实际的IE窗口最小化。这在IE的所有版本中通过IETester发生,但是如果我在IE9中运行完整版本,则会启动兼容性模式,并且由于某些原因而不能最小化。



I我尝试了各种加载脚本的方法(在示例代码中注释),所有这些都产生了相同的行为。



为什么会发生这种情况?有没有办法?



http:// jsfiddle.net/Xeon06/RCsuH/

解决方案

这是一个已知问题在jQuery mobile中。违规行是 jquery.mobile。 navigation.js:913

  //杀死键盘。 
// XXX_jblas:我们需要停止抓取整个文档来杀死焦点。相反,
//我们应该使用一个live()处理程序来跟踪焦点,所以在这一点上我们已经有了
//这个元素。
//将它放在try / catch块中,因为IE9抛出Unspecified error,如果document.activeElement
//在IFrame中未被定义。
尝试{
$(document.activeElement ||).add(input:focus,textarea:focus,select:focus).blur();
} catch(e){}

blur()将IE窗口发送到堆栈的后面。



作为解决方法,您可以通过将脚本标签<在< head>

 <!DOCTYPE HTML> 
< html>
< head>
< link rel =stylesheethref =http://code.jquery.com/mobile/latest/jquery.mobile.css/>
< script src =http://code.jquery.com/jquery-1.6.2.js>< / script>
< script src =http://code.jquery.com/mobile/latest/jquery.mobile.js>< / script>

...

将脚本标签放在文档的其他位置或插入他们通过脚本触发错误。



这个小提琴< a>演示了行动中的解决方法。请注意,这仅适用于顶级文档。如果文档在< iframe> 中,则该错误仍将显示。因此,如果您在IE 7/8中打开JSFiddle编辑器,它仍将被发送到后面;但是如果您仅打开呈现的HTML ,则不会。


Okay, this is by far the weirdest bug I have ever encountered. It's pretty straightforward though. If I load jQuery and then jQuery mobile dynamically in any version of Internet Explorer, the actual IE window minimizes. This happens in all versions of IE through IETester, however, if I run the full version in IE9, it kicks compatibility mode and for some reason doesn't minimize.

I've tried various ways of loading the scripts (commented in the example code), all resulting in the same behaviour.

Why is this happening? Is there a way around it?

http://jsfiddle.net/Xeon06/RCsuH/

解决方案

This is a known issue in jQuery mobile. The offending line is jquery.mobile.navigation.js:913.

// Kill the keyboard.
// XXX_jblas: We need to stop crawling the entire document to kill focus. Instead,
//            we should be tracking focus with a live() handler so we already have
//            the element in hand at this point.
// Wrap this in a try/catch block since IE9 throw "Unspecified error" if document.activeElement
// is undefined when we are in an IFrame.
try {
    $( document.activeElement || "" ).add( "input:focus, textarea:focus, select:focus" ).blur();
} catch(e) {}

There's the call to blur() that's sending IE windows to the back of the stack.

As a workaround, you can avoid this by placing the script tags physically in the <head> of the HTML.

<!DOCTYPE HTML>
<html>
  <head>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
    <script src="http://code.jquery.com/jquery-1.6.2.js"></script>
    <script src="http://code.jquery.com/mobile/latest/jquery.mobile.js"></script>

...

Placing the script tags elsewhere in the document or inserting them via script triggers the bug.

This Fiddle demostrates the workaround in action. Note that this only works in a top-level document. If the document is in an <iframe>, the bug will still appear. Thus, if you open the JSFiddle editor in IE 7/8, it will still get sent to the back; but if you open just the rendered HTML, it will not.

这篇关于动态加载jQuery mobile会导致IE最小化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆