PDA

View Full Version : conditional disable contextmenu in iframe on Ext.window



valititi
14 Dec 2010, 6:07 AM
I have a Ext.window. With some textfields in it and a tinymce editor. In attached image (snap.png) you can see WHERE i need to disable the contextmenu. For other zones on the screen is relatively simple (oncontextmenu=return false, etc).

I look with and Ext.util.DelayedTask for finding the iframe (who take 1-2 seconds to render and is not visible before this time)...
I don't know, i don't find yet. Please help.
So, I need to disable contextmenu on the bottom zone of this iframe.
23815

Thanks!

Condor
14 Dec 2010, 7:36 AM
You will need to attach the contextmenu event handler to the IFRAME document, but you first have to wait until the document is available (by polling if it exists).

To get the document you can use:

var win = Ext.isIE ? iframe.contentWindow : window.frames[iframe.name],
doc = Ext.isIE ? win.document : (iframe.contentDocument || win.document);
(but I'm sure that TinyMCE also has a method for this)

valititi
14 Dec 2010, 8:32 AM
can look stupid, but i am really curios where it is. With a Ext.util.DelayedTask, after 10 seconds, i add :



obj2 = document.getElementsByTagName("iframe");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("html");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("body");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("tbody");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("span");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("textarea");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("tr");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("td");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("table");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("div");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}
obj2 = document.getElementsByTagName("form");
for(ii=0;ii<obj2.length;ii++){obj2[ii].oncontextmenu=function(){return false}}

obj = window.frames[0].document;
obj.oncontextmenu=function(){return false}
obj = document.getElementById("mMsg_ifr"); // this is the tinyMCE iframe
obj.oncontextmenu=function(){return false}



I also tried to add listeners on the "mMsg" item of the form, at declaration time...
this context menu always stay !
:-(
please help !