admin管理员组

文章数量:1414923

I have a webpage that uses an iFrame (see .html) and (of course) the iFrame shows up with a white background in IE instead of the blue background in firefox and chrome. I have tried everything to make the background of the iframe blue/transparent include:

  • adding the "allowtransparency=true" tag to the iframe
  • adding a "background-color: blue" & "background-color: transparent" tag to the inside of the iframe using javascript
  • enclosing the iframe in a span tag with "background-color: blue"
  • changing the iframe to a div (wouldnt work because I am using AJAX to get the source from a XML file and the XMLHttpRequest object can only be used once)

If anyone knows a solution to my problem then please let me know. I should also note that the only success I had was with style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)".

Thanks!

I have a webpage that uses an iFrame (see http://little-apps/lilregcleaner/history.html) and (of course) the iFrame shows up with a white background in IE instead of the blue background in firefox and chrome. I have tried everything to make the background of the iframe blue/transparent include:

  • adding the "allowtransparency=true" tag to the iframe
  • adding a "background-color: blue" & "background-color: transparent" tag to the inside of the iframe using javascript
  • enclosing the iframe in a span tag with "background-color: blue"
  • changing the iframe to a div (wouldnt work because I am using AJAX to get the source from a XML file and the XMLHttpRequest object can only be used once)

If anyone knows a solution to my problem then please let me know. I should also note that the only success I had was with style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)".

Thanks!

Share Improve this question asked May 20, 2011 at 0:16 SameOldNickSameOldNick 2,4571 gold badge28 silver badges34 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 2

Setting the IFRAME BODY's style attribute to background-color:blue works for me in IE8's debugger. (That is, the BODY of the document loaded in the IFRAME.)

Alternatively, you could use JavaScript to change the BODY's styles directly:

document.getElementById("versionHistory").contentWindow.document.body.style.backgroundColor="blue";
// get the IFRAME window object, get the BODY tag in that window, set its CSS

I think you have to add the background in the page loaded in the iframe.

Example, modify http:/little-apps/lilregcleaner/history/1.xx.html

本文标签: javascriptTrying to change background color of iFrame in IEStack Overflow