JQuery mobile dynamic loading makes IE minimize

Well, this is by far the strangest mistake I have ever encountered. It is pretty simple. If I download jQuery and then jQuery mobile dynamically in any version of Internet Explorer, the actual IE window minimizes. This happens in all versions of IE via IETester, however, if I run the full version in IE9, it launches compatibility mode and for some reason does not minimize it.

I tried various ways to load scripts (commented out in the sample code), all this leads to the same behavior.

Why is this happening? Is there any way around this?

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

+6
source share
2 answers

This is a known issue in jQuery mobile device. Offensive line 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 a blur() call that sends IE windows to the back of the stack.

As a workaround, you can avoid this by placing script tags physically in the <head> 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 script tags elsewhere in the document or pasting them through a script causes an error.

This script demonstrates a workaround in action. Note that this only works in a top-level document . If the document is in an <iframe> , an error will be displayed. Thus, if you open the JSFiddle editor in IE 7/8, it will still be sent back; but if you open only rendered HTML , it will not.

+3
source

My attempt to "install": http://jsfiddle.net/RCsuH/6/

@ josh3736 was almost exactly right, somewhere in the code he runs document.body.blur() , which minimizes the window.

My fix is ​​simply replacing this function with the no-op function. I was not able to get the script tags to start the download after the download is complete, so the replacement of the function (if necessary) is up to you.

However, all this seems to be a bug in the jQuery Mobile library, and therefore you should probably provide an error report. However, I'm not sure if this bothers them too much, that there is a bug in IE for a framework designed for mobile phones / tablets.

Note. This is terrible, terrible code that replaces native functions. If possible, do not use it.

+1
source

Source: https://habr.com/ru/post/895688/


All Articles