javascript - removing body background color of iframe - Stack Overflow

I have a an iframe on my page that currentlyhas a background color of grey, I want to change the color

I have a an iframe on my page that currentlyhas a background color of grey, I want to change the color to be white but cant seem to do it. I have tried using jquery but not sure if this is correct:

$(document).ready(function(){
    $('iframe').contents().find('body').css('backgroundColor', 'white');
});

basically at the moment the bo tag within the iframe has the inline background-color: #f1f0e9

can anyone suggest how I can update this background color? i've tried css also but nothing.

The problem is on this page .html

The iframe is the booking element and the background color of this extends down the page because an iframe height had to be added to allow for all booking options to be shown when selected?

I have a an iframe on my page that currentlyhas a background color of grey, I want to change the color to be white but cant seem to do it. I have tried using jquery but not sure if this is correct:

$(document).ready(function(){
    $('iframe').contents().find('body').css('backgroundColor', 'white');
});

basically at the moment the bo tag within the iframe has the inline background-color: #f1f0e9

can anyone suggest how I can update this background color? i've tried css also but nothing.

The problem is on this page http://cromorevillage./book.html

The iframe is the booking element and the background color of this extends down the page because an iframe height had to be added to allow for all booking options to be shown when selected?

Share Improve this question edited Jun 4, 2011 at 12:53 styler asked Jun 4, 2011 at 12:34 stylerstyler 16.5k25 gold badges85 silver badges139 bronze badges 2
  • Does the src attribute of the iframe have matching domain, protocol and port to its parent page? – alex Commented Jun 4, 2011 at 12:43
  • @alex no the iftame is external – styler Commented Jun 4, 2011 at 12:51
Add a ment  | 

3 Answers 3

Reset to default 2

My ment...

Does the src attribute of the iframe have matching domain, protocol and port to its parent page?

Your response...

No the iframe is external.

The reason you can not change it is because of Same Origin Policy.

$(document).ready(function(){
    $('iframe').contents().find('body').attr('bgcolor', 'white');
});
.css('background-color', 'white');

background-color is the css style you are looking for.


You need to add a P3P header with the value of CP="CAO PSA OUR" to allow cross-domain interfacing.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745301597a4621466.html

相关推荐

  • javascript - removing body background color of iframe - Stack Overflow

    I have a an iframe on my page that currentlyhas a background color of grey, I want to change the color

    14小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信