access dhtmlxWindow content

Hi,



I have created a dhtmlxWindow, attached a url using ajax, and am trying to access an element within it.



I created the window like so:



----------

var dhxWins = new dhtmlXWindows();

var ajaxApplicationWindow = null;

function ajaxApplicationWindowOpen(title, url)

{

ajaxApplicationWindow = dhxWins.createWindow(‘ajaxApplicationWindow’, 0, 0, 400, 570);

ajaxApplicationWindow.centerOnScreen();

ajaxApplicationWindow.setText(title);

ajaxApplicationWindow.denyResize();

ajaxApplicationWindow.button(“park”).disable();

ajaxApplicationWindow.button(“park”).hide();

ajaxApplicationWindow.button(“minmax1”).disable();

ajaxApplicationWindow.button(“minmax1”).hide();

ajaxApplicationWindow.attachURL(url, true);

}

ajaxApplicationWindowOpen(‘foo’, ‘foo.html’);

----------





I’ve written a function to get at the element using your example:



----------

function getWindowElementById(windowId, elementId)

{

if (_isIE)

{

return dhxWins.window(windowId)._frame.contentWindow.document.getElementById(elementId);

}

else

{

return dhxWins.window(windowId)._frame.contentDocument.getElementById(elementId);

}

}

----------





I am trying to access the element like so…



alert(getWindowElementById(‘ajaxApplicationWindow’, ‘id’).value);



…but it errors in Firefox with ‘dhxWins.window(windowId)._frame is null’ :-/



Please advise.

Hello,
You use ajax loading. The pages aren’t placed into iframes. So, you can try a simple approach:

function getWindowElementById(windowId, elementId)
{
return document.getElementById(elementId);
}
 

Works great, thanks!

I had made the mistake of referencing an id that didn’t exist (oops) which naturally errored. I assumed it was because I needed to access the iframe.