I have an iframe that loads a page inside it.. when a link is clicked on the page in the iframe, resize the body of the parent aka the document that has the iframe's body..


Example:

Body         <------------------------
   Iframe                            |
       Page                          |
         Link... Upon Click, resize --

How do I do the above? I tried Parent.document.body.style.width = "200px". and it didn't work. Not sure what to do. Please Help!

function Parentresize(id)
{
    var newheight = 2000;
    var newwidth = 2000;
    parent.document.getElementById(id).height= (newheight) + "px";
    parent.document.getElementById(id).width= (newwidth) + "px";
}

That would be cross-browser scripting (XSS - one page's JavaScript manipulating a site from another source) and it should not be allowed, for very good security reasons.

Back up, rethink and redesign.

And, sorry, I know you didn't want to hear this.

That would be cross-browser scripting (XSS - one page's JavaScript manipulating a site from another source) and it should not be allowed, for very good security reasons.

Back up, rethink and redesign.

And, sorry, I know you didn't want to hear this.

It indeed is NOT manipulating another site's..

My site has an iframe with a page loaded in it.
Upon button click, resize MY site's body + My Iframe's width.

I have solved it anyway and it works but thanks for at least replying.

My solution:

function WindowSize()
{
	WinWidth = 0, WinHeight = 0;	//Initialize variables with a value of 0;
	if(typeof(parent.window.innerWidth) == 'number')	//Well I need the parent width of the iFrame aka browser width. Width is a number, not undefined..
	{
			//FireFox/Opera..
		WinWidth = parent.window.innerWidth;
		WinHeight = parent.window.innerHeight;
	}
	else if(parent.document.documentElement && (parent.document.documentElement.clientWidth || parent.document.documentElement.clientHeight))
	{
		//IE 6+
		WinWidth = parent.document.documentElement.clientWidth;
		WinHeight = parent.document.documentElement.clientHeight;
	}
	return WinWidth;
}

function BodyResize(ID)
{
	var IDTag = parent.document.getElementById(ID);
	
	if(IDTag.clientWidth == '1024')
		IDTag.style.width = (WindowSize() + 'px');
	else
		IDTag.style.width = '1024px';
}
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.