How to prevent iframe from redirecting top-level window with HTML?

Spread the love

Sometimes, we want to prevent iframe from redirecting top-level window with HTML.

In this article, we’ll look at how to prevent iframe from redirecting top-level window with HTML.

How to prevent iframe from redirecting top-level window with HTML?

To prevent iframe from redirecting top-level window with HTML, we set the sandvox attribute.

For instance, we write

<iframe src="url" sandbox="allow-forms allow-scripts"></iframe>

to set the sandbox attribute to allow-forms allow-scripts to prevent iframe from redirecting the top level window.

Conclusion

To prevent iframe from redirecting top-level window with HTML, we set the sandvox attribute.

Leave a Reply

Your email address will not be published.