Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by A. Odendaal on Mar 19, 2008 07:17
open dhtmlx forum
Drag and Drop errors

Hi,

I am having some problems with the drag and drop functionality of dhtmlxTree. I have basically tried to duplicate the examples that come with the download but using the codeigniter framework. I have a class that builds the tree data and I load it into the tree with loadXMLString. This works perfectly but when I drag an item I get the following error.

Error: uncaught exception: Permission denied to get property Window.dhtmlDragAndDrop

The only reference I get to this error says that it is caused by cross domain security. I don't get it, everything is on my local computer as I am developing offline.

Any help would be greatly appreciated.
Answer posted on Mar 19, 2008 08:46
>>Error: uncaught exception: Permission denied to get property Window.dhtmlDragAndDrop
Such error doesn't related to DOJO directly. While initiating drag-n-drop component check parent window and all frames/iframes - is any of it also contain dhtmlx component (this check necessary to enable drag between frames). The "Permission denied" error means that in one of frames/iframes loaded document from another domain. Documents from another domain not accesible by script so browser throws error.

There is no way the drag will work correctly over  such iframe because of cross domain securite, but you can at least prevent js error while d-n-d init by next modification in dhtmlxCommon.js

Locate next code

if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
    window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);

and

if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
    window.frames[i].dhtmlDragAndDrop.initFrameRoute
(window,((!win||mode)?1:0));


and surround it by try|catch construction ( there is no legal way to detect is iframe available for scripting or not )

try{
if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
    window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
} catch(e){}

try{
if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
    window.frames[i].dhtmlDragAndDrop.initFrameRoute
(window,((!win||mode)?1:0));
} catch(e){}

Attachments (1)