Both main window and iframe are on the same domain, but what I want to achieve is to resize iframe to fit its contents using js only within that iframe.
I also do no
Assuming you have only 1 IFRAME in the main window, from the Javascript of the IFRAME's document you can do something like:
function getMySelf()
{
return (window.parent.document.getElementsByTagName("iframe"))[0];
}
var myself = getMySelf();
myself.style.width = whateverWidth;
myself.style.height = whateverHeight;