the Rainbow Networks
+++eXy FFA
Map: q3dm12
Players: 2 / 18
The golden pot › RAINBOW NETWORKS › Tech & Support › autoscaling iframe
autoscaling iframe
Something wrong with our servers or your system?
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexTech & Support
View previous topic :: View next topic  
Author Message
jackthompson
Admin
Admin


Joined: Aug 15, 2007
Posts: 1302
Location: Here

PostPosted: Tue Sep 14, 2010 6:25 pm    Post subject: autoscaling iframe Reply with quote

ever wanted to use an iframe to embed content but the scrollbars made it look shitty?

well here is a solution that will scale the iframe automatically to fit the size of its content...

(the comments are there because i comment stuff that might be necessary for a case i haven't tested... bla)

the drawback here is that it only works when the content in the iframe comes from the same domain :(


Code::
<html>  
<head>
<script>

function autoscaleiframe (f)
{
// scales iframe to the size of its content
// RESTRICTIONS: iframe content must be from the *same* domain as this file
// tested with FF and IE8

//var d = f.contentDocument;
var w = f.contentWindow;
var width = 
        w.document.body.scrollLeft ||
        w.document.body.scrollWidth
//        d.body.scrollLeft ||
//        d.body.scrollWidth
;
var height =
        w.document.body.scrollTop ||
        w.document.body.scrollHeight
//        d.body.scrollTop ||
//        d.body.scrollHeight
;
f.style.width = parseInt(width) + 10 + 'px';
f.style.height = parseInt(height) + 10 + 'px';
}  

</script>
</head>
<body>
<iframe onload="javascript:autoscaleiframe(this);" src="test40_.html" frameborder="0" marginwidth="0" marginheight="0 scrolling="no"></iframe>
</body>
</html>  
Back to top
View user's profile
Falkland
Übergod
Übergod


Joined: Aug 01, 2008
Posts: 922
Location: Nowhere

PostPosted: Wed Sep 15, 2010 7:05 pm    Post subject: Re: autoscaling iframe Reply with quote

Just in topic but (maybe) not so much ... the latest releases of Mozilla browsers support now the X-Frame-Options HTTP response header

developer.mozilla.org/...nse_header

so it will be possible to force the sameorigin or deny the page visualization in a frame or iframe.
Back to top
View user's profile
jackthompson
Admin
Admin


Joined: Aug 15, 2007
Posts: 1302
Location: Here

PostPosted: Wed Sep 15, 2010 7:29 pm    Post subject: Re: autoscaling iframe Reply with quote

i see... so frames are practically dead except you have also control over the page that is loaded in the frame...

so my script is useful again \:D/
Back to top
View user's profile
Falkland
Übergod
Übergod


Joined: Aug 01, 2008
Posts: 922
Location: Nowhere

PostPosted: Sat Sep 18, 2010 7:37 pm    Post subject: Re: autoscaling iframe Reply with quote

jackthompson wrote:
i see... so frames are practically dead except you have also control over the page that is loaded in the frame...

so my script is useful again \:D/

*cough* *cough* ... sorry jack ... but they already thought about this ; there is a boolean option in mozilla to force frame resize :

Code::
layout.frames.force_resizability
Back to top
View user's profile
jackthompson
Admin
Admin


Joined: Aug 15, 2007
Posts: 1302
Location: Here

PostPosted: Sun Sep 19, 2010 11:47 am    Post subject: Re: autoscaling iframe Reply with quote

kb.mozillazine.org/Lay...ility#True
the about:config default is the old behaviour

the attribute can, maybe, enabled again by using
e=document.getElementsByTagName('iframe');for(..) e[...].noresize='false';
onload or something...

however.. there is still the same-domain hurdle.. so using this makes only sense on a webhost without php...
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum Index -> Tech & Support All times are GMT + 1 Hour
Page 1 of 1


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Welcome Anonymous


Membership:
Latest: kontol
New Today: 0
New Yesterday: 0
Overall: 355

People Online:
Members: 0
Visitors: 18
Total: 18
Who Is Where:
 Visitors:
01: The golden pot
02: Home
03: The golden pot
04: The golden pot
05: Home
06: Maps
07: The golden pot
08: Home
09: The golden pot
10: The golden pot
11: The golden pot
12: The golden pot
13: Home
14: The golden pot
15: The golden pot
16: Servers & High Scores
17: Home
18: The golden pot

Staff Online:

No staff members are online!

The Rainbow Networks website is hosted by JockeTF and Soder on furver.se.

The Rainbow Networks
Interactive software released under GNU GPL, Code Credits, Privacy Policy
Azul theme and related images designed by Jamin