Hi,
I'm having trouble with an iframe-related issue.
I have a document (parent) with an iframe (child). If the parent document calls a function in the child which changes the childs url using window.location to a relative url, that url becomes relative to the parent document. Let me illustrate.
Parent document: /test/parent.html
Child document: /projects/child.html
Child code:
function moveOn(){
window.location.href = "newPage.html";
}
Parent code:
childDocument.contentWindow.moveOn();
Result: Child document tries to access /test/newPage.html instead of /projects/newPage.html
Is there any way of fixing this from the parent? I am in a situation where I can't make changes in the child document code, only in the parent.
Thanks, Nik
Edit:
This is the actual code
In parent (/testr/testr.html):
testr.appHolder = $("childIframe");
testr.appHolder.src = "../projects/test.html";
testr.functionName = "moveOn";
testr.appHolder.contentWindow[testr.functionName]();
In child (/projects/test.html):
function moveOn(){
window.location.href = "newPage.html";
}