Categories
JavaScript Answers

How to refresh an iframe using JavaScript?

Spread the love

Sometimes, we want to refresh an iframe using JavaScript.

In this article, we’ll look at how to refresh an iframe using JavaScript.

How to refresh an iframe using JavaScript?

To refresh an iframe using JavaScript, we call iframe.contentWindow.location.reload();.

For instance, we write

const iframe = document.getElementById("youriframe");
iframe.contentWindow.location.reload();

to get the iframe with getElementById.

Then we call iframe.contentWindow.location.reload to reload the iframe.

Conclusion

To refresh an iframe using JavaScript, we call iframe.contentWindow.location.reload();.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *