x-frame-bypass
x-frame-bypass copied to clipboard
Cannot navigate inside iframe
I have encountered a new issue after successfully loading https://www.hackernews.com/ inside an iframe:

This prevents navigation inside this iframe, which makes the site unusable. How do you guys work around this?
My theory is that in order to make this work, I'll need to move this code outside of the inline block and inside its own JS file:
this.srcdoc = data.replace(/<\/head>/i, `<base href="${url}">
<script>
// X-Frame-Bypass navigation event handlers
function onChatInABoxClick(e) {
if (frameElement && document.activeElement && document.activeElement.href) {
e.preventDefault();
frameElement.load(document.activeElement.href);
}
}
function onChatInABoxSubmit(e) {
if (frameElement && document.activeElement && document.activeElement.form && document.activeElement.form.action) {
e.preventDefault();
if (document.activeElement.form.method === 'post') {
frameElement.load(document.activeElement.form.action, {
method: 'post',
body: new FormData(document.activeElement.form),
});
} else {
frameElement.load(document.activeElement.form.action + '?' + new URLSearchParams(new FormData(document.activeElement.form)));
}
}
}
document.addEventListener('click', onChatInABoxClick);
document.addEventListener('submit', onChatInABoxSubmit);
</script>
</head>`);
Okay, moving the navigation event handlers into its own script resolved two of the errors, but these two errors remain:

Any ideas on how to resolve these remaining errors?