I try adding frame-scr since it says that "Note that 'frame-src' was not explicitly set": heres what I have try adding :
frame-src 'self';
frame-src 'self' data:;
frame-src http://example.com/;
frame-src http://* https://*;
Still error I have change the frame-src many times and don't have any luck fixing the error.
Here is my Content-Security-Policy:
default-src 'self' data: ; object-src 'none'; frame-ancestors 'self'; sandbox allow-forms allow-same-origin allow-scripts; base-uri 'self';"
Here is my HTML :
<div id="main">
<a href="" id="link">Click me</a><br>
</div>
<div id="popup"><iframe id="popupiframe"></iframe></div>
<div id="popupdarkbg"></div>
Here is my JS :
document.getElementById("link").onclick = function (e) {
e.preventDefault();
document.getElementById("popupdarkbg").style.display = "block";
document.getElementById("popup").style.display = "block";
document.getElementById('popupiframe').src = "http://example.com/";
document.getElementById('popupdarkbg').onclick = function () {
document.getElementById("popup").style.display = "none";
document.getElementById("popupdarkbg").style.display = "none";
};
return false;
}
window.onkeydown = function (e) {
if (e.keyCode == 27) {
document.getElementById("popup").style.display = "none";
document.getElementById("popupdarkbg").style.display = "none";
e.preventDefault();
return;
}
}
I encounter this error when I click the button/text the will trigger the iframe that will show another website in iframe.
Refused to frame 'http://example.com/' because it violates the following Content Security Policy directive: "default-src 'self' www.gravatar.com fonts.googleapis.com fonts.gstatic.com". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.