Calculate height of iframe problem in asp page with external link

Discussion in 'Javascript' started by Robert de Ridder, Nov 7, 2005.

  1. I use an asp page to display pages, where the dynamic content is in an
    iframe.
    To calculate the height of the iframe I use the calcheight function. However
    when trying to do this with external pages, I get an access denied error,
    and the iframe won't display correctly.
    Is there a way to solve this or another way to calculate the height for the
    iframe.
    The relevant code displayed below.

    Thanks in advance for any help,
    Robert


    function for calculating the height of the iframe:

    function calcHeight()
    {
    //calculate height
    var the_height=
    document.getElementById('hoofdframe').contentWindow.
    document.body.scrollHeight;

    //minimal height of 600
    if (the_height < 600) {the_height=600}

    //change height
    document.getElementById('hoofdframe').height=
    the_height;
    }


    the iframe:

    <iframe name="hoofdframe" id="hoofdframe" width="630" onload="calcHeight();"
    src="<%=session("urlsessie")%>" scrolling="no" height="1"
    frameborder="0"></iframe>
    Robert de Ridder, Nov 7, 2005
    #1
    1. Advertising

  2. Robert de Ridder

    VK Guest

    Robert de Ridder wrote:
    > I use an asp page to display pages, where the dynamic content is in an
    > iframe.
    > To calculate the height of the iframe I use the calcheight function. However
    > when trying to do this with external pages, I get an access denied error,
    > and the iframe won't display correctly.
    > Is there a way to solve this or another way to calculate the height for the
    > iframe.


    You cannot change security while acting from the top to the bottom
    (from your parent document to your iframe). Otherwise what kind of
    security would it be?

    If you are dealing with documents from the same domain, you can use
    IE-only (?) document.domain property.

    So if in *both* documents (parent one and in iframe) you have:
    ....
    document.domain = "myserver.com";
    ....
    then security communication block will be removed for all documents
    served either from "http://www.myserver.com" or
    "http://subdomain.myserver.com" and so on.

    If your documents are from totally different domains then you have
    either
    1. Kill security settings on each computer
    2. Have a script in each document served to iframe so it would *itself*
    report to its parent the needed info.

    I would definitely stay on the 2nd option.
    :)
    VK, Nov 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    14
    Views:
    13,763
  2. mi
    Replies:
    4
    Views:
    13,445
    dorayme
    May 21, 2008
  3. Zsolt Koppany

    How to calculate the height of a text?

    Zsolt Koppany, Nov 18, 2003, in forum: Javascript
    Replies:
    3
    Views:
    88
    Evertjan.
    Nov 18, 2003
  4. Daedalous
    Replies:
    3
    Views:
    663
    Daedalous
    Jan 16, 2004
  5. Joe Attardi
    Replies:
    0
    Views:
    493
    Joe Attardi
    Jan 17, 2006
Loading...

Share This Page