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.
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
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.
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
this is interesting can anyone give an example? I am trying to focus a particular content only using iframe