|
|
Subject:
how can i use window.resizeto function in an iframe and make it work in firefox?
Category: Computers > Programming Asked by: rdnpa-ga List Price: $6.00 |
Posted:
20 Jan 2005 14:06 PST
Expires: 19 Feb 2005 14:06 PST Question ID: 460621 |
In my website there is a page called iframe.asp and that page is displayed in several other websites within an iframe. Those websites use this code: <iframe src="http://www.mywebsite.com/iframe.asp" width=150 height=200 name="mywebsite" id="mywebsite" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 scrolling=no></IFRAME> The problem is the content of the iframe has changed, therefore the height of the iframe has to change as well. But since, i don't want to ask several websites to update their iframe html code, i want the iframe resize it self dynamically. I found the following code which does what i want: <SCRIPT LANGUAGE="javascript"> <!-- width=700; height=180; window.resizeTo(width,height); //--> </SCRIPT> This code works fine in int explorer but does not work in firefox. Is there a way of fixing that code so that it can work in firefox as well? or is there any other way that i can use to resize the iframe without asking several website owners to update their html code? ps: i checked my firefox settings, and resizing windows option is enabled. | |
|
|
There is no answer at this time. |
|
Subject:
Re: how can i use window.resizeto function in an iframe and make it work in firefox?
From: dominik1234-ga on 31 Jan 2005 10:46 PST |
Try this: <script language="javascript" type="text/javascript"> <!-- var myframe = parent.document.getElementsByName(window.name)[0]; myframe.height = 800; myframe.width = 800; //--> This will only work if there is no other iframe with the same name on the same page! |
Subject:
Re: how can i use window.resizeto function in an iframe and make it work in firefox?
From: sm70-ga on 16 Feb 2005 17:57 PST |
Try this: 1. Define onload on your asp's (iframe.asp) body tag. Ex: <body onload="javaScript:adjustFrame()"> 2. add following in your asp's head section. I'm assuming that all your clients using "mywebsite" as ID for your iframe.asp. <script language="javascript"> function adjustFrame(id){ var id = "mywebsite" parent.document.getElementById(id).style.display = ""; if (document.all){ parent.document.getElementById(id).style.height=(this.document.body.scrollHeight+5)+"px" }else if(document.documentElement && document.documentElement.scrollHeight ) { parent.document.getElementById(id).style.height=(this.document.documentElement.scrollHeight+5)+"px" }else{ parent.document.getElementById(id).style.height=(this.document.body.scrollHeight+5)+"px" } if (document.all){ parent.document.getElementById(id).style.width=(this.document.body.scrollWidth+5)+"px" }else if(document.documentElement && document.documentElement.scrollWidth ) { parent.document.getElementById(id).style.width=(this.document.documentElement.scrollWidth+5)+"px" }else{ parent.document.getElementById(id).style.width=(this.document.body.scrollWidth+5)+"px" } } </script> Tested on IE 6.0, Netscape 7.0, Firefox. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |