Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-resize IFRAME - ok in IE, not FF :/

Status
Not open for further replies.
Define 'not working'? What does it do that it shouldn't? What doesn't it do that it should?

You've given no clues whatsoever to help us to help you.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi,

Basically, it should make the IFRAME as high/wide as the page that was loaded inside it :)

The code I'm using, is as follows:

Code:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 3</title>

<script type="text/javascript">
 function autofitIframe(id){
   if (!window.opera && !document.mimeType && document.all && document.getElementById){
   parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
   parent.document.getElementById(id).style.width=this.document.body.offsetWidth+"px";
   }
    else if(document.getElementById) {
   parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
   parent.document.getElementById(id).style.width=this.document.body.offsetWidth+"px";
  }
} 
</script>
</head>

<body>

<iframe  frameborder="0" style="border:0;"  id="myframe1" name="myframe1" src="[URL unfurl="true"]http://www.google.com"[/URL] onload="autofitIframe('myframe1');"></iframe>

</body>

</html>

TIA

Andy
 
Anyone got an idea? :/

TIA

Andy
 
Basically, it should make the IFRAME as high/wide as the page that was loaded inside it :)

In which case, it doesn't work properly in IE6 or IE7 either, as for those browsers the iframe is made as high as window, not the content loaded within the iframe.

Have you tried using ".scrollHeight" or ".clientHeight" instead of ".offsetHeight"?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi,

Thanks for the reply. I've just tried those options (".scrollHeight" or ".clientHeight") - and neither of them work in FF either :/ (both work fine in IE)

Not sure where to go from here :(

Cheers

Andy
 
BTW, this is the error I get in FF:

Error: [Exception... "'Permission denied to get property HTMLDocument.body' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]v

You can test the script here:


Please - anyone got any ideas? :/ I really need to get this working :( (unless anyone can think of a better way, to include content from another site - on a page ???)

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top