Hi Friends,

Working with communication between a child javascript window and parent jsp function, I am trying to access a function defined in the parent jsp from its child window which is a separate js file. This logic works fine in IE, but breaks in Chrome.
* Parent function: multiCreateCallback()

  • Child JS code to access multiCreateCallback
    [CODE]
    var windowCmp = parent.Ext.getCmp('workflowTaskWindow');
    var frameVar = windowCmp.getEl().dom.getElementsByTagName("iframe")[0];
    console.log("Frame test: "+ frameVar.contentDocument.frames.multiCreateCallback());
    [/CODE]

No matter what combination I use with frameVar, I can't seem to reach the callback function. 'contentDocument.frames' says undefined
'contentWindow.document.multiCreateCloseCallback()' also gives 'undefined' as error.
'parent.multiCreateCloseCallback();' - gave the error as - Uncaught TypeError: undefined is not a function

Is there any way to handle the code such that we can reach the callback function defined in the parent JSP?

Thanks in advance!
Nikita

If I understand you correctly, you are trying to call a Javascript function, which is located inside the parent window, from an iframe (child of the parent window). If you are using JQuery, this post may answer what you want (using dolink). However, the function seems to be forbidden to use locally (with file:/// or drive letter in the URL).

Hi Taywin,

Thanks for the reply. I am using extJS and not jQuery, so can't make use of dolink.

Oops my bad. The dolink() is a function name defined inside your parent window. The window.parent is the object referred to your parent window. So inside your child (frame) window, use window.parent.AFunctionNameInsideParentWindow(). Hope this would give you some ideas.

I was able to resolve this using following snippet:

var windowCmp = parent.Ext.getCmp('workflowTaskWindow');
var frameVar = windowCmp.getEl().dom.getElementsByTagName("iframe")[0];
console.log("Frame test: "+ frameVar.contentWindow.frames.multiCreateCallback());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.