Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 2nd, 2010, 01:59 AM
Authorized User
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default auto resize iframe and Safari


I have the followinf code that works great in IE and FF but in safari only 50%

In Safari my iframe resizes when the content is larger that the carrent iframe size but doesnt "shrink" when the content in the iframe is shorter than the previous content.

Also I cannot use a script that uses the 'onload' event on the iframe as my client doesnt want the page to refresh.

any ideas would be helpfull.

<script type="text/javascript"><!--
function doIframe(){
    o = document.getElementsByTagName('iframe');
        if (/\bautoHeight\b/.test(o[i].className)){
            addEvent(o[i],'load', doIframe);

function setHeight(e){
        e.height = e.contentDocument.body.offsetHeight + 35;
    } else {
        e.height = e.contentWindow.document.body.scrollHeight;

function addEvent(obj, evType, fn){
    obj.addEventListener(evType, fn,false);
    return true;
    } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
    } else {
    return false;

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);    

<iframe src="inc_rambleArticle.asp?ramblePostID=<%=ramblePostID%>" name="autosizeframe" id="autosizeframe" width="425" marginwidth="0" marginheight="0" align="left" scrolling="no" frameborder="0" class="autoHeight"></iframe>
Old January 25th, 2011, 12:35 PM
Registered User
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Love to Answer your Question.

Inorder to solve your Problem There are Two Scenario's

1. Trying to Resize of the Iframe From the Same Domains

2. Trying to Resize of the Iframe From Different Domains.

I believe, The Following Article http://www.ittreats.com/os/javascrip...-the-page.html Explained Both the Scenario's and also Will Help you out about the Issue with a Definite Solution.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto resize DudTrap General .NET 0 November 14th, 2008 01:43 PM
javascript in safari arafat.eajaz Javascript 0 September 5th, 2008 02:06 AM
values from one iframe to another iframe URGENT raaj Beginning PHP 2 February 27th, 2007 12:19 PM
Auto Refresh and Auto Delete deontae45 VB.NET 2002/2003 Basics 1 September 29th, 2006 04:53 PM
Safari Browser Larson HTML Code Clinic 0 February 11th, 2004 10:55 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.