Removing tinyMCE Editor.onKeyPress event - breaks in Opera
-
08-12-2019 - |
Question
I am using a tinyMce editor in our website. At the first pageload I set an onkeypress event handler like this:
window.onload = function () {
tinyMCE.activeEditor.onKeyPress.add(function () { startCookieInterval() });
}
This works fine in firefox and chrome, but in opera it throws this javascript error:
Uncaught exception: TypeError: Cannot convert 'tinyMCE.activeEditor' to object
So I changed the window.onload to document.onload in case the tinyMce editor hasn't properly initialised by window.onload. This then works fine, up to the point where the event handler is called for the first time. Here I remove the event handler, because I only want to run it once:
function startCookieInterval() {
tinyMCE.activeEditor.onKeyPress = null;
cookieIntervalTick();
}
After this, on every keypress, the following javascript error occurs:
[07/05/1983 08:35:36] JavaScript - http://localhost:10166/4_advice_only/editadviceitem.aspx?ADIID=13127831
Event thread: keypress
Uncaught exception: TypeError: Cannot convert 'v[x[t.fakeType || t.type]]' to object
Error thrown at line 8641, column 20 in r(t, A) in http://localhost:10166/includes/tiny_mce_3_3_8/tiny_mce.js:
v[x[t.fakeType || t.type]].dispatch(v, t, A)
called via Function.prototype.call() from line 3686, column 16 in <anonymous function: g>(n) in http://localhost:10166/includes/tiny_mce_3_3_8/tiny_mce.js:
return l.call(j, n)
None of this happens in any other browsers. Please share your thoughts. Thanks
hofnarwillie
Solution
Opera is not fully supported by Tinymce. This might be the reason for your error.