I have a select
box in my page and it looks in this way:
<select id="bgselector" onchange="bg(this[this.selectedIndex].value);">
<option value="0.png" id="btn1">1. Default skin</option>
<option value="1.png" id="btn2">2. MK7 Collage</option>
<option value="3.jpg" id="btn3">3. Full Darkness</option>
</select>
When I click an option (thanks to the bg();
function) the background of the page changes. By the way there is also an iframe inside my body.
When the body background changes, I want that my iframe changes the background too, so I wrote the following code:
$(function() {
var iframe_body = $('iframe').contents().find('body');
var set_bg = function(url) {
$('iframe').contents().find('body').css('background-image', 'url(' + url + ')');
$('iframe').contents().find('body').css('opacity', 1.0);
}
$('#bgselector').change(function() {
set_bg($(this).val());
});
$('#btn1').click(function(){
set_bg('http://mk7vrlist.altervista.org/backgrounds/0.png');
});
$('#btn2').click(function(){
set_bg('http://mk7vrlist.altervista.org/backgrounds/1.png');
$("body").css('opacity', 1.0);
});
$('#btn3').click(function(){
set_bg('http://mk7vrlist.altervista.org/backgrounds/3.jpg');
$("body").css('opacity', 0.9);
});
});
With the jQuery above, when I change the background of my body, the background of the page in my iframe changes.
The problem is that when I change the page in the iframe, the background changes into the original one (instead of the same of the body). How could I fix this?