Perhaps you're wondering about possible changes to make, here are a couple of options:
<iframe id="theframe" src="something.pdf" style="background-color: #FFF;" />
You could also achieve this using CSS:
<iframe id="theframe" src="somthing.pdf"/>
CSS:
#theframe{
background-color: blue;
}
If there's any confusion about your request, please clarify if you want the change to be immediate or only when prompted.
EDIT: The color change will only display if the source fails to load, otherwise it will remain as is.
EDIT: To implement this with a button (using the example above), I've added a single button along with the script. Hopefully, this helps:
<script>
function change(){
if(document.getElementById("thebutton").innerHTML == "light"){
document.getElementById("thebutton").innerHTML = "dark";
document.getElementById("theframe").contentWindow.document.body.style.backgroundColor = "white";
}
else{
document.getElementById("thebutton").innerHTML = "light";
document.getElementById("theframe").contentWindow.document.body.style.backgroundColor = "black";
}
}
</script>
<button id="thebutton" type="button" onclick="change();">Dark</button>
<iframe id="theframe" src="" />
If you'd like to use two buttons for this task, simply insert the code that modifies the frame into each button, for example:
<button id="thebutton" type="button" onclick="document.getElementById("theframe").contentWindow.document.body.style.backgroundColor = "black";">Dark</button>
<button id="thebutton" type="button" onclick="document.getElementById("theframe").contentWindow.document.body.style.backgroundColor = "white";">Light</button>
<iframe id="theframe" src="" />
I hope this information proves helpful. If it answers your question, feel free to mark it so others can benefit from it as well.