<!-- Fiddle Start -->
<h2>IE focus problem in iFrame</h2>
<button onclick="openPopup()">open</button>
<div id="innerHTML" style="display: none">
<!--suppress HtmlFormInputWithoutLabel -->
<textarea style="width: 300px; height: 170px; margin-bottom: 5px;">
Some sample text here.
Some sample text here.
Some sample text here.
Some sample text here.
Some sample text here.
</textarea>
<br />
<input type="button" onclick="parent['closePopup']();" value="close" />
</div>
<p>To reproduce:</p>
<ol>
<li>open this page with IE10 / IE11</li>
<li>click "open"</li>
<li>click on "some sample text"</li>
<li>click "close"</li>
<li>click "open"</li>
<li>click on "some sample text"</li>
</ol>
<p>Expected results: text gets the focus and shows the caret.</p>
<p>Actual results: text does not get the focus.</p>
<input type="button" onclick="burn(this)" style="width: 250px" value="Start burning your IE" />
<!--suppress HtmlFormInputWithoutLabel -->
<input type="text" id="loopCount" value="10000" style="width: 50px" />
<p>IE is so interesting :( </p>
<p>if you keep your browser busy (click the above button), the issue would be gone.</p>
<p>Maybe the cpu burning task is scaring her 😱 </p>
<!-- Fiddle End -->
/*
* Copyright (c) 2014 Mailtech.cn, Ltd. All Rights Reserved.
*/
function closePopup() {
// $(".overlay").remove();
document.body.removeChild(document.body.lastChild);
}
function iFrameHTML() {
return "<html>"
+ "<head><title>Focus test, IFrame</title></head>"
+ "<body style='background-color: #EEE'>"
+ document.getElementById("innerHTML").innerHTML
+ "</body>"
+ "</html>";
}
function openPopup() {
// Append to DOM
document.body.insertAdjacentHTML('beforeEnd',
'<div class="overlay"><iframe src="javascript:parent.iFrameHTML();"></iframe></div>');
// ??? This is needed to reproduce the bug!
// $popupIFrame.on('load', function () {});
}
function burn(button) {
if (burn.intervalID) {
clearInterval(burn.intervalID);
burn.intervalID = 0;
button.value = 'Click me again to burn';
return;
}
var loopCount = parseInt(document.getElementById("loopCount").value) || 10000;
// set not idle
burn.intervalID = setInterval(function () {
var x = 0;
for (var i = 0; i < loopCount; i++) {
x = (x + Math.random() * 1000) >>> 0;
}
button.value = 'Click me to stop: ' + x;
}, 1000);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.