Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is it possible for the IFRAME module to automatically detect the height of the target url and scale accordingly. This would mean the IFRAME always displays without a scroll bar.
And if not, can we have master settings for width and height? i.e. not exposed to the users in a cck field?
Comment | File | Size | Author |
---|---|---|---|
#21 | iframe-360549-21.patch | 4.66 KB | neffets |
#10 | iframe-360549-3.patch | 5.83 KB | tobiassjosten |
#7 | iframe-360549-2.patch | 5.79 KB | tobiassjosten |
#6 | iframe-360549.patch | 5.63 KB | tobiassjosten |
Comments
Comment #1
neffets CreditAttribution: neffets commented1) it is possible to detect the height of the iframe, BUT only if the iframe-content is from the same domain (same-origin-policy by the browsers)
see:
get http://schuessler-reisen.de/sites/all/js/iframe_resize.js and adjust the iframeid Variable at top.
You have to include it in your master-Template page.tpl.php
2) You can give master width and height, when You add the iframe-cck-fields on your "content-types" (e.g. story, btw. page)
(if this is not working for You file a bug-report please)
n
Comment #2
neffets CreditAttribution: neffets commentedComment #3
Leiche CreditAttribution: Leiche commentedHi,
thats the answer that I was searching for.
But I have a small problem with it, because I'm not a great programmer.
What is the "iframeid" and where can I look it up?
How do I include the JavaScript into my page.tpl.php?
Can I use my theme page.tpl.php?
Sorry for this stupid questions, but like I said I'm totally new to tweaking Drupal files in this way.
Cheers Leiche
Comment #4
Leiche CreditAttribution: Leiche commentedDoh ... sorry for this post, but I forgot to reactivate the issue :(
Comment #5
MarcElbichon CreditAttribution: MarcElbichon commentedSee insertframe module
Comment #6
tobiassjosten CreditAttribution: tobiassjosten commentedI rolled a patch which allows you to set an automatic height. Because resizing an iframe is only possible between the same domain, I also added an proxy PHP script that will serve your external pages through your own domain. All relative paths are kept by use of the base tag.
In short, this lets you set the height to 'auto'.
Comment #7
tobiassjosten CreditAttribution: tobiassjosten commentedAdded functionality to proxy also URLs with paths, like example.com/page, and URLs with queries, like example.com?query=example. I also fixed the base tag injection so that it considers paths, for relative URLs.
Comment #8
gwink CreditAttribution: gwink commentedThis is not working for me. I have this
I also tried with iframe id="iframe-0"
Finally, I tried height="100%"
any thoughts/ideas?
Comment #9
tobiassjosten CreditAttribution: tobiassjosten commentedDid you apply the patch successfully? Have you tried setting the height to 'auto' instead of '100%'?
Your problem could also be related to a bug in Iframe, #664838: Conflicting iframe IDs, if you are using more than one iframe per page.
Comment #10
tobiassjosten CreditAttribution: tobiassjosten commentedRealizing this wont work too well on cached iframes (cached CCK field, cached block, cached view, etc) I decided to put the javascript inclusion in hook_init() and made it work on all iframe tags with an 'auto' height. This also helped clean the code up some.
Comment #11
amitaibuFrom reading code:
- Why the use of curl and not drupal_http_request?
- Maybe instead 'auto' we can accept 0. I think it's better for a field to be of the same type (a number and not mixed).
Comment #12
manoelhc CreditAttribution: manoelhc commentedThe function drupal_http_request() doesn´t support proxy. That is so bad.
Curl should support DNS cache.
Comment #13
mario0455 CreditAttribution: mario0455 commentedHi,
can someone please explain step by step, how to do all this?
" You have to include it in your master-Template page.tpl.php" - where to include very top before "php", this cause top errors, body errors... head errors, or it is some part of the code.
"iframe_resize.js " - i have to create this file in my template master folder?
"You can give master width and height" -What this means, master? "100%" "auto"
A big part of us are only common mortals ;-)
Thank you for your time.
Comment #14
tobiassjosten CreditAttribution: tobiassjosten commentedThe proxy script doesn't bootstrap Drupal, for performance reasons, and so it doesn't have access to drupal_http_access(). You do have a point though - that function, I believe, have a fallback for curl-less environments and so should this proxy.
It turns out IE doesn't support resizing like this, at all. I don't know why or if it can be made to work. One solution would be to put the "auto" metadata outside the height property and let the height value only control the initial height of the iframe. If the tag supports it, maybe rel="autoheight" would work?
Comment #15
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedSubscribing.
Comment #16
Frederic wbase CreditAttribution: Frederic wbase commentedHello
I have downloaded version 6x 1.3 of the module and aplyed the path to it, but it doesen't work for me. The iframe always gets the height of 700px.
The iframe is loaded from another domain.
Anyone has an idea?
grts
frederic
Comment #17
alebening CreditAttribution: alebening commentedplease explain me more deatil how to adjust the frameid and how to include it in master template page.tpl.php...
sorry for dumb question...:D
Comment #18
chipway CreditAttribution: chipway commented@tobiassjosten,
Did you apply your patch to the latest 6.x-1.8 version ?
For me it works for same domain content in iFrame, but i still can't make it work with the proxy script.
Comment #19
chipway CreditAttribution: chipway commentedI applied patch #10 on the latest 6.x-1.8 version, then fixed it, but there is still an issue :
First content loaded in the iframe gives the right height to the iframe, but as soon as i click in the iframe, the height is no more fitted to new content (keeps first content height), as height is evaluated on onload of my page.
I keep investigating the issue and listening to any idea to fix it.
Thanks
Comment #20
neffets CreditAttribution: neffets commentedMy 10cents:
Comment #21
neffets CreditAttribution: neffets commentediframe.js added to git.
Because I prefer adding "autoresize" to the class definition, I enabled css-class-editing on single-node-level.
The js reacts on iframe.autoresize selector.
If one want to add the foreign-domain support with a menuaction a la "/iframe/load//
", he is invited. Inside it can use the preferred drupal_http_request method. So its save against open-proxy problem. What would be the best method to support resizing not only at load of page? Should we recall every 10 seconds, or does exist an event "iframe-changed / location of iframe changed"?Comment #22
marinex CreditAttribution: marinex commentedHi, I came across a solution based on easyXDM. Maybe it should be good solution for cross domain communications between drupal sites.
Marinex
Comment #23
neffets CreditAttribution: neffets commentedAdded the "autoresize"-feature in the drupal 7 branch too.
(its only works for same origin -iframes.)