Home › Forums › JavaScript › Resizing an iframe – Script problems
- This topic is empty.
-
AuthorPosts
-
September 11, 2009 at 11:31 pm #26076
Indubitable Turtle
MemberHey guys. On one of the sites I maintain, I’m using a bit of JavaScript to dynamically resize an iframe, which contains a photo gallery. I realize that using iframes is not optimal, but in this case, I’m fairly certain it is the best option. Anyway, I"m having an issue with the script, which I found after some hectic Googling and now can’t even recall where. I know about as much JavaScript as I know quantum physics, so figuring out how to fix it by myself would be a real adventure in learning. I thought I’d present the issue to you kind folks here first.
Basically what happens is that the script does exactly what it is supposed to on page load—assesses the height of the content called within the iframe and adjusts the height of the iframe accordingly, to eliminate vertical scrollbars. However, when clicking on an album within the iframe, it does not resize again to accommodate for the resulting significant decrease in height of content. It does, quite contrarily, do this on the other site I have the script implemented on, quite nicely.
Code://Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: [“myframe1”, “myframe2”] or [“myframe”] or [] for none:
var iframeids=[“photoframe”]//Should script hide iframe from browsers that don’t support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide=”no”var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf(“Firefox”)).split(“/”)[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 30 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsersfunction resizeCaller() {
var dyniframe=new Array()
for (i=0; iI would really appreciate any assistance on this. Even a suggestion for a different script, or a better way of accomplishing this would be great!
Many thanks in advance.
September 16, 2009 at 9:38 pm #64243bmdsherman
MemberMaybe you could try and break through the frame on the second page.
September 17, 2009 at 2:34 am #64256Indubitable Turtle
MemberHmm, thanks, but I’d really like to be able to maintain the iframe, as breaking out of it would mean no access to the main site navigation. I could open it in a new window, but I find that rather intrusive, and can’t stand when it’s done to me, so I’m a bit against that as well.
AuthorPostsViewing 3 posts - 1 through 3 (of 3 total)- The forum ‘JavaScript’ is closed to new topics and replies.