I was wondering!! O.o, how could we access other page controls from a page using JavaScript/Jquery. But this sample gave me the solution.
var url = parent.document.referrer;
var obj = parent.document;
// this find can be used to find the control by id or by control type.
// then we can use the control the way usually do with client side
//scripting
$(obj).find('control name');
}
Hope this sample helps you :) ... If you face any prob with this post a comment will reply ASAP ...
From Iframe page (child page) access Parent page controls:
function AccessParentPage(){var url = parent.document.referrer;
var obj = parent.document;
// this find can be used to find the control by id or by control type.
// then we can use the control the way usually do with client side
//scripting
$(obj).find('control name');
}
From Iframe page (child page) access Parent page js methods:
This is pretty simple you just need to add "parent" keyword in the beginning to call methods in parent page.eg.
if "validate()" was the method in parent page then simply you can call "parent.validate()" from Iframe page.From Parent page access Child page controls:
function AccessChildPage() {
var obj = document.getElementById('iframe id').contentWindow.document;
$(obj).find('control name').each(function () {
//your code
});
}
From Parent page access Child page js methods:
function AccessChildPage() {
document.getElementById('iframe id').contentWindow.method name(parameters);
}
Hope this sample helps you :) ... If you face any prob with this post a comment will reply ASAP ...
Comments