Reload page with JavaScript

In JavaScript, we can use the location.reload() to reload a page, which is part of the native JavaScript Window interface. location.reload(); Or a longer version. window.location.reload(); Table of contents: 1. Reload the page and bypass the cache 2. Reload page with JavaScript 3. References 1. Reload the page and bypass the cache The location.reload() method …

Read more

Check if element exists in JavaScript

In JavaScript, we can use document.querySelector() to check if an element exists. The document.querySelector() searches for and returns the first element matching a selector or set of selectors. If it finds no matching elements, it returns null. For example, to check if an element with the id elementId exists: if (document.querySelector("#elementId")) { // The element …

Read more

Javascript call a function after page loaded

This article shows how to call a function after a page is loaded in Javascript. Table of contents: 1. Document: DOMContentLoaded event 2. Window: load event 3. Javascript calls a function after the page loaded 4. References 1. Document: DOMContentLoaded event In modern JavaScript, the most common way to run code after loading the page …

Read more