This jQuery tutorial, we will discuss how to run javascript only after the entire page has been loaded using jQuery.
Recently in one of the assignments, I wanted to call a JavaScript function after the page fully loaded. This thing we were trying inside a SharePoint web part page, where we were adding the code using a script editor web part.
We will discuss how to run JavaScript using jQuery after page load.
Run JavaScript after page loaded completely using jQuery
There is a difference between DOM is ready and when the whole page finished loading. Once the whole page finished loading you will be able to access images everything.
Our requirement is to run the code after the page has loaded.
We usually write document.ready() function which usually gets called immediately after DOM elements is ready.
By using jQuery and JavaScript, we will be able to resolve the issue.
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
$(window).bind("load", function() {
// code here
});
Above approach will surly work but you can try the below code also.
$(window).load(function() {
// your code hereā¦
});
You may like the following jQuery tutorials:
- Show SharePoint List Data using jQuery Datatable
- How to implement expand/collapse in HTML table rows using jQuery
- Display SharePoint list data in jQuery data table using Rest API
- Dropdown selected change event in jQuery Example
- How to handle radio button checked and unchecked events using JavaScript and jQuery
- JavaScript Examples PDF free download (51 Examples)
- How to call a javascript function when a checkbox is checked unchecked
I hope this will be helpful to run JavaScript after page loaded completely using jQuery.
Additional tags: jquery after page load, jquery on page load, jquery window load, jquery event after page fully loaded, call javascript function after page load complete, execute javascript after page load complete, run script after page load complete jquery, load javascript after page load, run javascript after page has loaded
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com