the Rainbow Networks
+++eXy FFA
Map: q3dm19
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: 59
Total: 59
Who Is Where:
 Visitors:
01: The golden pot
02: Maps
03: Home
04: Home
05: Rainbow Media
06: My Account
07: The golden pot
08: Home
09: The golden pot
10: The golden pot
11: Maps
12: Maps
13: The golden pot
14: Home
15: My Account
16: The golden pot
17: The golden pot
18: Maps
19: Maps
20: The golden pot
21: The golden pot
22: The golden pot
23: Maps
24: Home
25: Home
26: The golden pot
27: Maps
28: Home
29: The golden pot
30: The golden pot
31: The golden pot
32: The golden pot
33: Home
34: The golden pot
35: The golden pot
36: My Account
37: My Account
38: The golden pot
39: Home
40: Maps
41: Maps
42: Home
43: Home
44: The golden pot
45: The golden pot
46: The golden pot
47: The golden pot
48: The golden pot
49: The golden pot
50: The golden pot
51: The golden pot
52: The golden pot
53: The golden pot
54: The golden pot
55: The golden pot
56: Home
57: The golden pot
58: The golden pot
59: 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