Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot navigate inside iframe #52

Open
thdoan opened this issue Feb 15, 2023 · 2 comments
Open

Cannot navigate inside iframe #52

thdoan opened this issue Feb 15, 2023 · 2 comments

Comments

@thdoan
Copy link

thdoan commented Feb 15, 2023

I have encountered a new issue after successfully loading https://www.hackernews.com/ inside an iframe:

image

This prevents navigation inside this iframe, which makes the site unusable. How do you guys work around this?

@thdoan
Copy link
Author

thdoan commented Feb 15, 2023

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>`);

@thdoan
Copy link
Author

thdoan commented Feb 15, 2023

Okay, moving the navigation event handlers into its own script resolved two of the errors, but these two errors remain:

image

Any ideas on how to resolve these remaining errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant