Friday, 15 July 2011

javascript - Size the content of an IFrame or use an alternative -



javascript - Size the content of an IFrame or use an alternative -

i have 6 aspx pages want display within iframe when @ page can see array of controls contain web page.

but if utilize iframe cannot size content size of iframe although youtube resize content must way so.

so, how go making sure content fits iframe or there improve way of doing this. also, go page if command clicked not sure iframe has click event.

so, how go doing ?

if contents of iframe on same url main page shouldn't have security issues , can add together javascript content pages pass height of content main page. same click events: can have javascript phone call function on parent page.

here's illustration of main , iframe content page. content page has button can click resize iframe based on height of content.

main.htm

<html> <head> <script type="text/javascript"> function resize1(h) { document.getelementbyid("iframe1").height = h + 50; } </script> </head> <body> <div>test</div> <iframe id="iframe1" border="1" height="100" src="iframe.htm" width="200"> </body>

iframe.htm

<html> <body> <a href="#" onclick="parent.resize1(document.getelementbyid('content').clientheight);">resize iframe</a> <div id="content" style="background:red;height:500;width:50px;"> test content </div> </body>

you adapt suit needs. example, height set iframe content loads calling function in onload event of iframe content page.

note javascript functions want phone call on main page must in head section.

javascript iframe resize

No comments:

Post a Comment