CSS styling iframe page

Discussion in 'JavaScript' started by Yura, Sep 23, 2006.

  1. #1
    I have an affiliate shop with order page loading in iframe from another domain. I'm looking for a way to change CSS style of this iframe-page.

    mysite.com/buy.html looks like this:
    
    <HTML>
    <HEAD>
    
    <script type="text/javascript">
    function styleIFrame()
    { document.frames['orderframe'].document.body.style.backgroundColor="green";
    }
    </script>
    
    </HEAD>
    <body onload="styleIFrame();">
    
    <iframe id="orderframe" name="orderframe" src="https://ANOTHERdomain.com/order.html"></iframe>
    
    </body>
    </html>
    
    Code (markup):
    IE 6 throws JS-error: "Access is denied". I think this is because domains differ or because of httpS of iframe src. Are there any workarounds? Thanks.
     
    Yura, Sep 23, 2006 IP
  2. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Exactly, the security module implemented in the JScript parser of IE (an JavaScript one from Gecko based too) forbid remote scripting on a (i)frame outside the original domain. So you cannot access the frames properties this way :(
     
    Evoleto, Sep 23, 2006 IP
  3. Yura

    Yura Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Evoleto, thanks. And there are no solutions possible?
     
    Yura, Sep 23, 2006 IP
  4. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Yura, usually there is always a solution in implementation but different in approach but I unable to suggest since I don't know exactly what do you want to accomplish. The only suggestion I have for now (but I have no idea if it is appliable to your case) would be to grab the HTML page from the remote server, and postprocess it on your server before displaying it (you can search & replace the styles you want etc) - but again, I don't know if it's suitable for you.
     
    Evoleto, Sep 23, 2006 IP
  5. Yura

    Yura Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, I was thinking about php+curl. Thanks again.
     
    Yura, Sep 23, 2006 IP
  6. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,

    You can use file_get_contents() to retrieve a remote URL on a PHP install with URL extensions enabled.

    Scripting between frames sourced from different domains is not permitted as it constitutes a cross-site-scripting vulnerability.

    Regards
    - P
     
    penagate, Sep 27, 2006 IP
  7. dannygsam

    dannygsam Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    this is interesting can anyone give an example? I am trying to focus a particular content only using iframe
     
    dannygsam, Jul 28, 2009 IP