Accordion attachURL(url) getFrame() document empty

Hi Folks,

I am using an accordion to which I add three items. The third item gets it’s content from a call to attachURL(url) and the iframe is loaded successfully and I can see it’s content in the DOM. Unfortunately when I try to access any of the HTML elements within the iframe I get a null value. The code follows:

accordion.addItem(“b1”, “Foo”);
accordion.addItem(“b2”, “Bar”);
accordion.addItem(“b3”, “Baz”);

var iFrameObj = subAccordion.cells(“b3”).getFrame();
var iframe = iFrameObj.contentWindow;

var findMe = iframe.document.getElementById(“findMe”);

The findMe variable is always null. If I print the iframe object to the console it looks like an iframe, but it’s #document property is empty, even though it is visible in the DOM.

Any help would be much appreciated.



Please note my typo, the subAccordion.cells(“b3”).getFrame() should be accordion.cells(“b3”).getFrame(). Sorry 'bout that.

Also please note that when I print the iframe to the console:

var iframe = iFrameObj.contentWindow;
console.log(“iframe =”, iframe);

it shows that iframe is a Window object. If I can provide any further details, please let me know.


I’m thinking the attachURL(url) code is running asynchronously so the content is not yet available, however I’ve tried telling it not to use ajax:

accordion.cells(“a2”).attachURL(url, false);

but that didn’t work either. I’ve tried to see if there is a “onContentLoaded” or some such event handler for an accordion, but so far haven’t found anything.

Again, any help would be much appreciated.



Ok, I’ve answered my own question. For anyone having any similar problem this is the solution I am using successfully:

accordion.attachEvent(“onContentLoaded”, function() {
var iframe = accordion.cells(“a2”).getFrame().contentWindow;
var findMe = iframe.document.getElementById(“findMe”);
console.log("findMe div = ", findMe); // prints:

find me


Sure do wish the DHTMLX documentation was a bit more thorough.

Best Regards,