How To Reload/Refresh A Page Using Javascript In Addition To Jquery
JavaScript provides several ways to reload or refresh an HTML page merely the criterion way to exercise this task is past times using window.location object. This object provides a reload() method which instructs the browser to reload the page. The browser tin exercise it from its cache or from the server, which depends upon optional parameter i.e. reload(true) volition reload the page from the server merely reload(false) volition alone reload the page from browser's cache, which may or may non stand upward for the electrical flow version at the server.
You tin combine both jQuery together with JavaScript to wrap the page refresh code equally shown inwards our example. Btw, this is non the alone way to refresh a page inwards JavaScript, yous tin too usage history.go(0) together with location.replcace(locatoin.pathname) to reload the page.
Here is the sum instance for your reference:
That's all most how to reload or refresh a page inwards jQuery using JavaScript. Just recall that window.location.reload() volition teach the browser to reload the page, which way downloading information from the server, parsing, together with displaying it. You tin too reload a page from browser's cache past times using the location.reload(false) method. You tin read to a greater extent than most jQuery methods on jQuery inwards Action book, 1 of the best resources to larn together with usage jQuery inwards existent globe projects.
Further Reading
The Complete jQuery Course: From Beginner To Advanced!
Up together with Running alongside jQuery
jQuery Fundamentals By Dan Wahlin
You tin combine both jQuery together with JavaScript to wrap the page refresh code equally shown inwards our example. Btw, this is non the alone way to refresh a page inwards JavaScript, yous tin too usage history.go(0) together with location.replcace(locatoin.pathname) to reload the page.
JavaScript together with jQuery instance to reload a page
In this example, I volition nation yous how to reload a page from both server together with browser's cache using jQuery together with JavaScript. In our HTML nosotros bring 2 buttons, 1 for reloading page from the server together with other from refresh page from browser's cache. Though location.reload() volition piece of job inwards all browser, yous tin too usage jQuery to wrap other code e.g. attaching a click handler to the 2 buttons.Here is the sum instance for your reference:
<html> <head> <title>How to reload/refresh a page using jQuery</title> </head> <body> <h2>Reloading a page using jQuery together with JavaScript</h2> <button id="btn_reload">Reload from Server</button> <button id="btn_refresh">Reload from Browser's cache</button> <script src="//code.jquery.com/jquery-1.6.2.min.js"></script> <script> $(document).ready(function() { $("#btn_refresh").click(function(){ location.reload(false); //loads from browser's cache }); $("#btn_reload").click(function(){ location.reload(true); //loads from server }); }); </script> </body> </html>
That's all most how to reload or refresh a page inwards jQuery using JavaScript. Just recall that window.location.reload() volition teach the browser to reload the page, which way downloading information from the server, parsing, together with displaying it. You tin too reload a page from browser's cache past times using the location.reload(false) method. You tin read to a greater extent than most jQuery methods on jQuery inwards Action book, 1 of the best resources to larn together with usage jQuery inwards existent globe projects.
Other jQuery articles for you
- 5 Books to larn jQuery for Web developers (books)
- How to acquire electrical flow URL, Parameters, together with Hash using jQuery? (solution)
- jQuery Hello World Example (program)
- How to usage to a greater extent than than 1 jQuery UI DatePicker inwards JSP page? (example)
- How to exercise tab-based UI using jQuery? (example)
- How to alter to a greater extent than than 1 chemical portion inwards 1 line? (example)
- How to redirect a page URL using jQuery together with JavaScript? (solution)
- How to write HelloWorld inwards jQuery? (solution)
- 20 jQuery Interview Questions for Java Web Developers (list)
- How to charge jQuery inwards a spider web page? (solution)
Further Reading
The Complete jQuery Course: From Beginner To Advanced!
Up together with Running alongside jQuery
jQuery Fundamentals By Dan Wahlin
Thanks for reading this article. If yous similar this tutorial together with hence delight portion alongside your friends together with colleagues. If yous bring whatever enquiry or feedback together with hence delight drib a comment.
Komentar
Posting Komentar