Home > Web Front-end > JS Tutorial > body text

How to Reload an iFrame in JavaScript Without Messy Code?

Susan Sarandon
Release: 2024-11-15 17:53:03
Original
952 people have browsed it

How to Reload an iFrame in JavaScript Without Messy Code?

Reloading iFrames with JavaScript

Want to refresh an iframe without compromising code aesthetics? Read on to discover a better solution than setting the src attribute to itself.

Problem:

How do I reload an iframe using JavaScript without resorting to untidy code practices?

Answer:

Leverage the contentWindow property:

document.getElementById('some_frame_id').contentWindow.location.reload();
Copy after login

Note: In Firefox, accessing window.frames[] by id doesn't work. Instead, use name or index.

The above is the detailed content of How to Reload an iFrame in JavaScript Without Messy Code?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template