Resizing frames with firefox

Discussion in 'Javascript' started by jeanor72, Jan 15, 2007.

  1. jeanor72

    jeanor72 Guest

    Hi all,

    I'm trying to fix some javascript code to make it work also with
    firefox.
    I have the following function in a href link in a frame used to make
    another frame ("uno") visible or invisible.

    --- start here --
    function resizeMenu() {
    var stretto = '0%,100%';
    var largo = '20%,80%';
    if ( window.parent.uno.cols == largo ) {
    window.parent.uno.cols=stretto;
    } else {
    window.parent.uno.cols=largo;
    }
    document.location.reload();
    }
    --- end here ---

    This works with MSIE, but doesn't with firefox.

    I read a lot over the internet, but didn't find anything useful to make
    the function also works for firefox.

    Note that Firefox console tells me:

    "Errore: window.parent.uno has no properties"

    But I don't know what to do to fix this.

    Can anybody help me please?

    Thank you,
    Gianluca
    jeanor72, Jan 15, 2007
    #1
    1. Advertising

  2. jeanor72 wrote:

    > if ( window.parent.uno.cols == largo ) {
    > window.parent.uno.cols=stretto;
    > } else {



    > Note that Firefox console tells me:
    >
    > "Errore: window.parent.uno has no properties"


    Use e.g.
    var frameSet = parent.getElementById('uno');
    if (frameSet != null) {
    if (frameSet.cols == largo) {
    frameSet.cols = = stretto;
    }
    else {
    frameSet.cols = largo;
    }
    }


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 15, 2007
    #2
    1. Advertising

  3. jeanor72

    ASM Guest

    jeanor72 a écrit :
    > Hi all,
    >
    > I'm trying to fix some javascript code to make it work also with
    > firefox.
    > I have the following function in a href link in a frame used to make
    > another frame ("uno") visible or invisible.
    >
    > --- start here --
    > function resizeMenu() {
    > var stretto = '0%,100%';
    > var largo = '20%,80%';
    > if ( window.parent.uno.cols == largo ) {
    > window.parent.uno.cols=stretto;
    > } else {
    > window.parent.uno.cols=largo;
    > }
    > document.location.reload();
    > }
    > --- end here ---
    >
    > This works with MSIE, but doesn't with firefox.


    This would work everywhere (except NC4 IE4)

    <html>
    <script type="text/javascript">
    function resizeMenu(sinistra,destra)
    {
    var attr = sinistra+'‰,'+destra+'‰';
    document.getElementById("general").setAttribute('cols',attr);;
    }
    </script>
    <frameset id="general" cols="20%,80%">
    <frame id="leftFrame" src="menu.htm">
    <frame id="rightFrame" noresize scrolling="no" src="frame_a.htm">
    </frameset>
    </html>

    file 'frame_a.htm' :

    <html>
    <a href="#" onclick="top.resizeMenu(0,100);return false;">hide menu</a>
    <a href="#" onclick="top.resizeMenu(20,80);return false;">show menu</a>
    </html>

    > Note that Firefox console tells me:
    >
    > "Errore: window.parent.uno has no properties"


    or you didn't give 'uno' as *name* for your frameset
    or frame 'uno' isn't in parent's frame where you call your function
    or FF doesn't like direct JS commands about its frames

    I vote for case 1 (you did give an id instead a name to your frameset)



    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Jan 15, 2007
    #3
  4. jeanor72

    jeanor72 Guest

    Hi Martin,

    thank you for your answer.

    > Use e.g.
    > var frameSet = parent.getElementById('uno');


    I tried this. It doesn't work and firefox console says:

    "Errore: parent.getElementById is not a function".

    Note that this way doesn't work even with msie.

    Gianluca
    jeanor72, Jan 15, 2007
    #4
  5. jeanor72 wrote:

    > "Errore: parent.getElementById is not a function".


    My bad, should of course be
    var frameSet = parent.document.getElementById('uno');

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 15, 2007
    #5
  6. jeanor72

    jeanor72 Guest

    Martin Honnen wrote:

    > My bad, should of course be
    > var frameSet = parent.document.getElementById('uno');


    It works!

    Thank you very very much!
    Thanks also to ASM.
    Your help has been very appreciated.

    Gianluca
    jeanor72, Jan 15, 2007
    #6
    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. Kevin
    Replies:
    0
    Views:
    745
    Kevin
    Nov 21, 2003
  2. Ernie Sty
    Replies:
    5
    Views:
    2,287
    Ernie Sty
    Oct 2, 2004
  3. Andy Steady

    Resizing Frames

    Andy Steady, Sep 26, 2003, in forum: Javascript
    Replies:
    0
    Views:
    72
    Andy Steady
    Sep 26, 2003
  4. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    340
    Proper
    Apr 21, 2009
  5. Proper
    Replies:
    0
    Views:
    191
    Proper
    Apr 18, 2009
Loading...

Share This Page