x-frame-bypass
x-frame-bypass copied to clipboard
How can this be used in iframe elements injected by JS
I am trying to use document.createElement('iframe') and setAttribute('is','x-frame-bypass') to create a dynamic iframe. But not sure how to make it work on the dynamic injected iframes.
The simplest way is: document.write('<iframe is="x-frame-bypass" src="..."></iframe>')
or element.innerHTML = '<iframe is="x-frame-bypass" src="..."></iframe>'
const ifrm = document.createElement('iframe'); ifrm.setAttribute('is', 'x-frame-bypass'); ifrm.setAttribute('width', '500px'); ifrm.setAttribute('height', '350px'); ifrm.setAttribute('src', 'your HTML URL');
Add function to onload. Assuming you've already reference Jquery.
<iframe is="x-frame-bypass" id="iframe" onload="oniFrameLoad(this)" src="https://..." width="100%" height="100%" frameBorder="0"></iframe>
<script>
function oniFrameLoad() {
var scriptTag = "....";
scriptTag += "}";
console.log(scriptTag);
//inject content into iframe
$('#iframe').contents().find('body').append($('<script>').html(scriptTag))
};
</script>