I have a javascript function "myFunction()" and i need to call this function on First page load only not for all page.
how can i do it.
I will appreciate a lot your help.
thanks
I have a javascript function "myFunction()" and i need to call this function on First page load only not for all page.
how can i do it.
I will appreciate a lot your help.
thanks
Share Improve this question asked May 24, 2013 at 20:16 Shamim AhmedShamim Ahmed 9312 gold badges16 silver badges30 bronze badges1 Answer
Reset to default 6The best is to store in localStorage
the fact that you already visited the site (to be precise it's the "origin").
You can put this code in all your pages :
<script>
if (!localStorage['done']) {
localStorage['done'] = 'yes';
myFunction();
}
</script>
If you want to show the page again for next session, replace localStorage
with sessionStorage
.