IE8 + iframe: window goes to background #2821

Closed
pbosakov opened this Issue Oct 24, 2011 · 4 comments

Projects

None yet

2 participants

@pbosakov
Contributor

When a jquery mobile page is loaded in an iframe, it causes IE8 browser window to lose focus.

Affected system:
Windows XP Professional SP3
Microsoft Internet Explorer 8

Steps to reproduce:

  1. Open any (non-minimized) application window in the background
  2. Open IE8 in the foreground, with only one browsing tab
  3. Go to http://www.bossakov.eu/temp/jqm-ifr-test/

Result:
The whole IE window goes in the background when the jquery mobile code executes.

Expected result:
The IE window should stay in the foreground.

@pbosakov
Contributor

Traced the issue to line 3028:

$( document.activeElement || "" ).add( "input:focus, textarea:focus, select:focus" ).blur();

Apparently in IE8, activeElement returns the body element, and using the blur() method on it causes this behaviour.

On my website I replaced this line with the following code. You may verify and possibly commit it.

if(document.activeElement) {
if(document.activeElement.nodeName.toLowerCase() != 'body') {
document.activeElement.blur();
}
} else {
$( "input:focus, textarea:focus, select:focus" ).blur();
}

@toddparker
Contributor

Thanks for tracking this down. Mind making a pull request?

@pbosakov
Contributor

Sure, I'll make a pull request as soon as I can. Thanks

@toddparker
Contributor

Closed by: 8387919

@toddparker toddparker closed this Nov 13, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment