changing Iframe's height from itself ..

Discussion in 'Javascript' started by Prasad, Nov 6, 2006.

  1. Prasad

    Prasad Guest

    Hi ,
    I am using a cross domain iframe in my page..
    If i want to change the iframe height a/c to its content height , its
    giving Permission denied error as i am trying to access a function,
    which changes an iframe's height, in the parent window ...


    So Is there any way to change its height from the iframe
    itself???????


    Plz help me out in this case ..........


    Thanx in advance..................
     
    Prasad, Nov 6, 2006
    #1
    1. Advertisements

  2. Prasad wrote:

    > So Is there any way to change its height from the iframe
    > itself???????


    As said (in de.comp.lang.javascript), for IE/Win you can use
    window.resizeTo(someWidth, someHeight)
    even on iframe window objects and it will resize the iframe. As for
    getting the document height, look into the function you already have, it
    is simply a question of accessing the right document properties e.g.
    window.resizeTo(document.documentElement.offsetWidth,
    document.documentElement.scrollHeight);
    where the only problem is that depending on the IE version and the
    rendering mode you need to access document.documentElement or document.body.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 6, 2006
    #2
    1. Advertisements

  3. Prasad

    Prasad Guest

    Martin Honnen wrote:
    > Prasad wrote:
    >
    > > So Is there any way to change its height from the iframe
    > > itself???????

    >
    > As said (in de.comp.lang.javascript), for IE/Win you can use
    > window.resizeTo(someWidth, someHeight)
    > even on iframe window objects and it will resize the iframe. As for
    > getting the document height, look into the function you already have, it
    > is simply a question of accessing the right document properties e.g.
    > window.resizeTo(document.documentElement.offsetWidth,
    > document.documentElement.scrollHeight);


    I am using a function ...........

    function changeHeight()
    {
    //
    window.resizeTodocument.documentElement.offsetWidth,document.documentElement.scrollHeight);

    // window.resizeTo(200,400);


    window.resizeTo(document.documentElement.offsetWidth,document.body.scrollHeight);


    setTimeout("changeHeight()",1000);
    }


    its first time called when iframe body is loaded ..
    But its behaving very wierd .. the height of the iframe is increasing
    and decreasing to some arbitrary value and after some time, an error
    that "Access is denied " is being displayed ...

    this iframe's domain is different from the parent's domain .....(but i
    dont guess its a problem ..)

    And i tested this function with a sample iframe in the same domain ..
    its working fine... ( )


    what could be the problem in the first case ??





    > where the only problem is that depending on the IE version and the
    > rendering mode you need to access document.documentElement or document.body.
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    Prasad, Nov 7, 2006
    #3
    1. Advertisements

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. Noozer

    Can iframe hide itself?

    Noozer, May 25, 2005, in forum: HTML
    Replies:
    8
    Views:
    20,403
    Alain
    Oct 20, 2006
  2. Replies:
    0
    Views:
    648
  3. Wotney
    Replies:
    1
    Views:
    600
    Flinky Wisty Pomm
    Oct 25, 2006
  4. Daedalous
    Replies:
    3
    Views:
    956
    Daedalous
    Jan 16, 2004
  5. Joe Attardi
    Replies:
    0
    Views:
    635
    Joe Attardi
    Jan 17, 2006
Loading...

Share This Page