hasFocus() returning error

JanC

New Member
I'm not quite sure what I am doing wrong, I looked up a way to see if an element has focus. I found the document.hasFocus() method. So I tried and I debugged on Chrome and got "Uncaught TypeError: Object # has no method 'hasFocus'.". Here is my JavaScript:\[code\]var e = document.getElementById("editor").contentWindow;e.document.designMode="on";e.document.open();e.document.write("<head><style>body{font-family:arial,helvetica,sans-serif;font-size:12px;}</style></head>");e.document.close();function def() { document.getElementById("fonts").selectedIndex = 0; document.getElementById("size").selectedIndex = 1; document.getElementById("color").selectedIndex = 0;}function edit(x, y) { e.document.execCommand(x, false, y); e.focus();}setInterval(function() { if (document.getElementById("editor").contentWindow.hasFocus()) { document.getElementById("html").value = http://stackoverflow.com/questions/12735372/document.getElementById("editor").contentWindow.document.body.innerHTML; } else if (document.getElementById("html").hasFocus()) { document.getElementById("editor").contentWindow.document.body.innerHTML = document.getElementById("html").value; }}, 100);\[/code\]
 
Back
Top