Dear all experts!
This is a Firefox related question.
Can someone show me how to dynamically add a keydown event to the iframe in the code below, so that the updateTa() function is executed and the text area updated with the HTML code of the iframe?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<head>
<title>My DHTML Editor</title>
<style type="text/css">
#DHTMLEditor,#DHTMLsrc{
width:500px;
height:500px;
}
#DHTMLsrc{
}
#DHTMLEditor{
border:1px solid #000000;
margin:0px;
}
</style>
<script type="text/javascript">
var bodyRef;
var taRef;
var editorRef;
function updateTa(){ // THIS FUNCTION IS NEVER EXECUTED ON FIREFOX - WHY?
taRef.value=bodyRef.innerH
TML;
alert('hello');
}
function initEvents(){
bodyRef.onkeyup=updateTa; // THIS DOESN'T WORK ON FIREFOX
}
function editorInit(){
taRef = document.getElementById('D
HTMLsrc');
if(!document.all){
document.getElementById("D
HTMLEditor
").content
Document.d
esignMode=
"on";
bodyRef= document.getElementById("D
HTMLEditor
").content
Document.b
ody;
editorRef= document.getElementById("D
HTMLEditor
");
bodyRef.innerHTML = document.getElementById('D
HTMLsrc').
value;
}else{
bodyRef = document.getElementById("D
HTMLEditor
");
editorRef = document.getElementById("D
HTMLEditor
");
bodyRef.innerHTML = document.getElementById('D
HTMLsrc').
value;
}
initEvents();
}
window.onload = editorInit;
</script>
</head>
<body>
<iframe frameborder="0" marginheight="0" marginwidth="0" id="DHTMLEditor"></iframe>
<textarea id="DHTMLsrc">Init <b>Content</b> is comming here</textarea>
</body>
</html>
Start Free Trial