changing css class from parent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DJ WIce

    changing css class from parent

    Hi,

    I have this situation:

    I have a main page with content and an IFRAME on it.
    The IFRAME has it's own style sheet and the body of that uses a class:

    <body class="IFbody">

    How can I change the backgroundcolor of the IFRAME via a function in the
    main page, activated from the main page.


    The scripts I found via google only access the styles on the main page via
    for example
    document.styleS heets

    The problem is that
    document.getEle mentById('IFid' ).document.styl eSheets

    Does not access the IFRAME stylesheet but the main page stylesheet.

    Any suggestion how to access it, would be great.
    Wouter


  • Martin Honnen

    #2
    Re: changing css class from parent



    DJ WIce wrote:
    [color=blue]
    > I have a main page with content and an IFRAME on it.
    > The IFRAME has it's own style sheet and the body of that uses a class:
    >
    > <body class="IFbody">
    >
    > How can I change the backgroundcolor of the IFRAME via a function in the
    > main page, activated from the main page.
    >
    >
    > The scripts I found via google only access the styles on the main page via
    > for example
    > document.styleS heets
    >
    > The problem is that
    > document.getEle mentById('IFid' ).document.styl eSheets
    >
    > Does not access the IFRAME stylesheet but the main page stylesheet.
    >
    > Any suggestion how to access it, would be great.[/color]

    You need to access the document in the iframe, a way to do that is to use
    <iframe name="iframeNam e" src="whatever.h tml"></iframe>
    then you can script
    var iframeDoc;
    if (window.frames && window.frames.i frameName) {
    iframeDoc = window.frames.i frameName.docum ent;
    // change iframeDoc.body. style.backgroun dColor here
    }
    --

    Martin Honnen


    Comment

    • DJ WIce

      #3
      Re: changing css class from parent


      : > Any suggestion how to access it, would be great.
      :
      : You need to access the document in the iframe, a way to do that is to use
      : <iframe name="iframeNam e" src="whatever.h tml"></iframe>
      : then you can script
      : var iframeDoc;
      : if (window.frames && window.frames.i frameName) {
      : iframeDoc = window.frames.i frameName.docum ent;
      : // change iframeDoc.body. style.backgroun dColor here
      : }

      Cool it works..
      So instead of using it's ID, give it a name and it wil listen ;-)

      Thanks!
      Wouter


      Comment

      • @SM

        #4
        Re: changing css class from parent

        DJ WIce a ecrit :[color=blue]
        >
        > Cool it works..
        > So instead of using it's ID, give it a name and it wil listen ;-)[/color]

        with your code does that would work ?

        parent.MiIframe .document.getEl ementById('IFid ').document.sty leSheets

        or in Gran'Ma's JS

        parent.MiIframe .document.bgCol or="#ffffcc';

        --
        ******** (enlever/remove [OTER_MOI] du/from reply url) *******
        Stéphane MORIAUX : mailto:stephane OTER_MOImoriaux @wanadoo.fr
        Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)

        *************** *************** *************** *************** **

        Comment

        Working...