SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iframe auto resize using php

    Hi there

    I have been made aware of a solution using php tp automatically risize the height of an iframe according to the amount of content.

    This gets around the problem of setting a fixed height for an iframe.

    Can anyone point me towards the php code which can achieve this

    any help is greatly appreciated

    thanks

  2. #2
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

    but can't it be done via php include command in anyway

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found this code. I just can't get it to work. the page loads ok but the iframe height is not adjusted. and an 'error on page' message comes up. it says access denied.

    can anyone suggest what might be wrong???

    You could insert the "iFrame" code below in your static page to achieve this:

    <script language="JavaScript">
    <!--
    function calcHeight()
    {
    //find the height of the internal page
    var the_height=
    document.getElementById('the_iframe').contentWindo w.
    document.body.scrollHeight;

    //change the height of the iframe
    document.getElementById('the_iframe').height=
    the_height;
    }
    //-->
    </script>


    <iframe width="500" id="the_iframe"
    onLoad="calcHeight();"
    src="yourform.htm"
    scrolling="NO"
    frameborder="0"
    height="1">
    An iframe capable browser is
    required to view this web site.
    </iframe>
    Last edited by yass2006; Dec 9, 2006 at 16:34.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any ideas

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    i have found the problem. I am using an external url on another domian. that is the reason i get access denied as the java script is unable to determine the content height.

    Has anybody got around this problem or can't it be solved

  7. #7
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you are doing good

  8. #8
    SitePoint Member
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You get the error because it is a security violation to do cross-domain scripting. Script from one domain cannot not modify content from another domain or modify the window that contains itwindow (iframe is a window object).

    To have control you have to deliver it from your own domain. Use PHP to connect to the remote site and bring the page onto your own server, then you can use the saved version of the page as the src of the iframe. However a word of caution if you do not have permission from the owner of the target page, you could bin in violation of copyright by serving it up from your own server.

    You may also still have trouble getting it to behave properly with javascript. If you really need tight control you should use ajax to bring it in and put it into a div after re-formating the tags.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •