...

View Full Version : iframe & designmode="on" focus not working on chrome...



boger
08-24-2011, 02:46 PM
Hi, i have the following html page


<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
<input type="text" id="input1" /><br />
<iframe id="textEditor" name="textEditor">
</iframe>
<script type="text/javascript">
$(document).ready(
function()
{
textEditor.document.designMode = "on";
textEditor.document.open();
textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:13px;}</style><body>Hi User<br /><br /><span style="font-style:italic;">### Write your message here ###</span><br /><br />Thanks,<br /></body></head>');

document.getElementById("textEditor").contentWindow.addEventListener('focus', OnFocus, true);
$("#input1").focus();
}
);

function OnFocus()
{
textEditor.document.body.innerHTML = textEditor.document.body.innerHTML.replace('<span style="font-style:italic;">### Write your message here ###</span>', "");
document.getElementById("textEditor").contentWindow.focus()
}
</script>
</body>
</html>


Now press on the tab key when the page loads (You should see focus on the textbox field) and you can see that the iframe text editor (WYSIWYG) has no focus... On firefox it works... How can i give it focus on chrome?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum