Contribute  :  Support  :  Downloads  :  Forum  :  Links  :  Polls  :  Calendar  :  Directory  :  Advanced Search  
Geeklog The Ultimate Weblog System
Welcome to Geeklog
Friday, May 16 2008 @ 02:39 AM EDT
   

Dynamic Resizable iFrame Solution Release Candidate 1

AnnouncementsThis should help your iframes dynamically resize on every new page load... Don't go crazy :)


------start--snip------

<html>
<!-- Please Do Not Remove or Modify This Comment
If you can add an improvement or enhancement to this script you're 1000% free to go ahead with it, just please
send your updates to vbgunz about your modifications to dexterslab@vbgunz.com... If you need the official script
you can try Geeklog for "dynamic resizable iframe" or email dexterslab@vbgunz.com for a copy.
// Please Do Not Remove or Modify This Comment-->

<!-- It is safe to remove this comment in production...
1a. Updates and modifications
1a. Introduction
2a. Thanks
3a. Geeklog installation instructions

1a. Introduction
----------------
This is a dynamic resizable iframe script... It resizes the iframe every time a new link within that iframe
is clicked... It works on IE6 and on Mozilla 1.2 and should work on Netscape 6+ browsers...

This script is only able to render iframes for the same domain or host... if localhost is hosting this script
it will only work calling in a localhost page... localhost cannot call 127.0.0.1 or 192.168.0.1 and vice versa.
Google has the better explaination at http://www.google.com/search?q=iframe%20cross%20domain%20script

2a. Thanks
----------
Major thanks to Kenny9336 at http://www.experts-exchange.com for the constructing of over 99% of this script...
Major thanks to Creator over at http://www.geeklog.net for suggesting a most powerful enhanced improvement...
Major thanks to vbgunz for 3 days in modifying this script over at Dexter's lab dexterslab@vbgunz.com
Major thanks to gator4life at http://www.experts-exchange.com for the explaination of iframe cross scripting...

3a. Geeklog installation instructions
-------------------------------------
Login and go to your static page section... Paste this script into the window and only change the iframe
src="http://localhost/" value to match your domain and directory... http://yourdomain.com/directory... You can
also modify whether scrolling and scroll are to be yes and margin widths, etc...

That's it... Happy iframing :)

// It is safe to remove this comment in production...
<head><title>Container</title>
<script language="JavaScript">
function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
</script>
</head>
<iframe onLoad="iFrameHeight();" src="http://localhost/" scrolling="no" scroll="no" id="iframename" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;"></iframe>
</body>
</html>

------start--snip------

Thanks Geeklog for the superb community and application ;)

Story Options

Dynamic Resizable iFrame Solution Release Candidate 1 | 9 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: Anonymous on Thursday, February 13 2003 @ 12:41 PM EST
Too funny. You say 99% of this script was written by someone else yet don't even mention him in the "Please Do Not Remove or Modify This Comment" part. I guess you want a ton of spam which you'll definitely get by having others place your email address in their webpages for bad bots to pick up. Don't worry, if I use this script, I'll be sure to add the link to your other post here.
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: Creator on Thursday, February 13 2003 @ 02:52 PM EST
Legalese aside, I've run into a problem with this script...

If you point the iframe src to pages that are local on your own server then the script works beautifully.

However, if you point the src to a page on another server (with another domain), the script will NOT work, as that server will deny access to the loading code. At least, that's what it is doing to me on the various sites I have tried this script on.

Also, the script does NOT work on the Mac IE 5.5. I have tried it with various event handlers to no avail. To compensate for this, I added height=800 to the iframe tag. On the PC IE 6.0 the script fires and the iframe height is automatically reset in spite of the height=800 attribute. On the Mac, it ignores the script but still loads the iframe at the specified height anyway.

The script itself does not need to be put between the head tags in header.thtml. It can simply be dropped in the same place along with the iframe code. Here is exact syntax I am using:


<script language="JavaScript">
function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = 
document.getElementById('iframename').contentDocument.body.scrollH
eight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
</script>
<iframe inLoad="iFrameHeight();" src="../stats.php" scrolling="no" 
scroll="auto" id="iframename" marginwidth="5" marginheight="5" 
frameborder="0" style="width:100%;" height=800></iframe>

Note: Change the inLoad event handler to the on Load one (without the space)

This will call a GeekLog's stats page into a static page.

Feature requests for whomever wants to help with the development of this fantastic piece of code:

  • Fix the Mac IE 5.5 bug somehow.
  • Fix the Access Denied bug so that this script will resize pages from external servers.

---
L. Whitworth
www.finiserv.com

Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: vbgunz on Thursday, February 13 2003 @ 03:35 PM EST
About my "please do not remove request" I'm just trying to stay on top of improvements to it... As for the script not being able to display correctly on IE 5.5... I am unable to answer that... I only tested the script on IE6 and on Mozilla 1.2...

I tried your improvement Creator and I like it... You're saying the head tags, etc are not needed... Cool... 800 is a fall back size incase the resize event doesn't fire right... Very cool...

As for the reason why you cannot display external webpages within the iframe I supposed is simple... It is a security issue called cross frame scripting... I put it in the comments section, the google explanation of it http://www.google.com/search?q=iframe%20cross%20domain%20script

This script does work great on your own server with your own pages but it does have a problem displaying some of your own content... For example phpMyAdmin... I cant get it to work on my server and for phpBB2 administration... I posted this script in hopes someone would be nice enough to modify it to work better than it currently is...

In case no one wishes to work with it it still is a great alternative to just using the regular iframe tag on your own content... Thanks Creator... I am off to check it out... (really love the fallback height value, sharp!)...

---
Victor B. Gonzalez
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: vbgunz on Thursday, February 13 2003 @ 03:51 PM EST
I just thought of something... you know how somesite are able to display another and when you look at the address it might look something like this...

http://www.samedomain.com/?http://www.differentdomain.com

Could this be somewhat an answer?

---
Victor B. Gonzalez
Dynamic Resizable iFrame Solution Release Candidate *2*
Authored by: vbgunz on Thursday, February 13 2003 @ 04:30 PM EST
<!-- Please Do Not Remove or Modify This Comment
If you can add an improvement or enhancement to this script you're 1000% free to go ahead with it, just please
send your updates to vbgunz about your modifications to dexterslab@vbgunz.com... If you need the official script
you can try Geeklog for "dynamic resizable iframe" or email dexterslab@vbgunz.com for a copy.
// Please Do Not Remove or Modify This Comment-->

<!-- It is safe to remove this line and the entire lower comment in production...
1a. Updates and modifications
1a. Introduction
2a. Thanks
3a. Geeklog installation instructions
4a. Notes

1a. Introduction
----------------
This is a dynamic resizable iframe script... It resizes the iframe every time a new link within that iframe
is clicked... It works on IE6 and on Mozilla 1.2 and should work on Netscape 6+ browsers...

This script is only able to render iframes for the same domain or host... if localhost is hosting this script
it will only work calling in a localhost page... localhost cannot call 127.0.0.1 or 192.168.0.1 and vice versa.
Google has the better explaination at http://www.google.com/search?q=iframe%20cross%20domain%20script

2a. Thanks
----------
Major thanks to Kenny9336 at http://www.experts-exchange.com for the constructing of over 99% of this script...
Major thanks to Creator over at http://www.geeklog.net for suggesting most powerful enhanced improvements...
Major thanks to vbgunz for 3 days in modifying this script over at Dexter's lab dexterslab@vbgunz.com
Major thanks to gator4life at http://www.experts-exchange.com for the explaination of iframe cross scripting...

3a. Geeklog installation instructions
-------------------------------------
Login and go to your static page section... Paste this script into the window and only change the iframe
src="http://localhost/" value to match your domain and directory... http://yourdomain.com/directory... You can
also modify whether scrolling and scroll are to be yes and margin widths, etc...

That's it... Happy iframing :)

4a. Notes
---------
This script in its original form detected an iframes *initial* height only. Every link within the iframe would
inherit the initial height. This script has been modified to resize on every new link and has been added a default
height of 5000 pixels in case this script runs into trouble detecting the initial height value and scroll has been
set to auto (Major thanks to Creator).

// It is safe to remove this line and the entire upper comment in production...-->

<script language="JavaScript">
function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
</script>
<iframe onLoad="iFrameHeight();" src="http://localhost/" scrolling="no" scroll="auto" id="iframename" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;" height="5000"></iframe>

---
Victor B. Gonzalez
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: Anonymous on Friday, February 14 2003 @ 03:13 PM EST
It figures you have no respect for another person's work and you want help? ROFLMAO, no way jerk.

I'll help out by reporting you to whichever site you rip off the content from so they can shut yours down.
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: vbgunz on Sunday, February 16 2003 @ 03:02 PM EST
You're not right in your statement so here I'll help you...

I'll tell you exactly where it is you can go to find the original script... http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20406264.html

I'll show you the profile of the person who written the script originally... http://www.experts-exchange.com/Web/Web_Languages/JavaScript/memberProfile.jsp?mbr=kenny9336

Can someone explain this to me? If the script is made public with no license what so ever towards a public question for help and it contains no comments, etc am I wrong for commenting on it because I would like to stay on top of it?

I tried getting in touch with the so called creator of the script but it proved impossible... I have no problems displaying footers on my front page and to remove a comment?...

The comments are provided as instructions... Instead of giving someone a zip file they can simply copy and paste... right direct off the thread...

As far as I know I didn't rip the script off someones page... It was made public for public usage... Am I really wrong for manipulating it to work the way I want and then helping others to achieve the same effect?

Its all good... I won't argue...


---
Victor B. Gonzalez
Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: Creator on Tuesday, February 18 2003 @ 11:09 AM EST
If you're so righteous why don't you post as yourself instead of anonymously like the coward you are?

The script in and of itself is not evil. Some people might find it useful for their own reasons. I, for one, am glad someone came up with it, because I can use it to grab my own pages outside of GeekLog and display them from within GeekLog.

Ain't nothing you can do but rage about it.

---
L. Whitworth
www.finiserv.com

Dynamic Resizable iFrame Solution Release Candidate 1
Authored by: kevdawg on Wednesday, June 30 2004 @ 05:33 PM EDT
The resize across domains will not work. it has to be the same, it's a security thing.

I use the try/catch function in my script so that it will not give an alert if it can't run.

function setSize() {
if(document.getElementById && !(document.all)) {

try {
h = document.getElementById('mainWin').contentDocument.body.scrollHeight;
document.getElementById('mainWin').style.height = h;
}
catch (e) {
//do nothing
}

}
else if(document.all) {
try {
h = document.frames('mainWin').document.body.scrollHeight;
document.all.mainWin.style.height = h;
}
catch (e) {
//do nothing
}

}
}