So, i have resolved problem on my own. But, anyway, thanks to @prabeen-giri who have helped me thinking in right way. Firstly, I need to explain preloaders mechanism. Just look at CSS:
position: fixed;
display: block;
top: 0; /* making preloader cover all screen */
right: 0;
left: 0;
bottom: 0;
background-repeat: no-repeat;
background-position:center; center;
background-size: auto auto;
background-image: url(../images/preload.png); /* your picture should be here */
background-color:#000;
z-index:99; /* must be the highest number of all others to cover them all */
So, your preloader just a picture or something else which cover all window and smoothly disappear (by jQuery) when whole content is loaded.
<div id="preloader" class="preloader"></div>
And here is script:
<script type="text/javascript">
$(window).load(function() {
$("#preloader").delay(700).fadeOut("slow");});
</script>
To resolve my problem and show preloader only once when entering site through domain name we need to use cookies. There are 2 cookie helper function (from Quirksmode):
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
So, we need to enter our own cookie to create the conditions for running the script. Initially our created cookie equals null and this equality will be condition to running the script. After that we set cookie some value to not start jQuery again. Here's code:
<script type="text/javascript">
$(window).load(function() {
if (readCookie('referer') == null){
$("#preloader").delay(700).fadeOut("slow");}
createCookie('referer',1,0);
});
</script>
But how to remove our preloader picture and background after refreshing the page? Because we just disable jQuery fadeOut proccess by our conditions. Picture and black background keep covering our window and not going to fade away...
Let's create new condition and place it in
<script>
if (readCookie('referer') == null) {
document.write("<style>.preloader {background-image: url(../images/preload.png); background-color:#000; z-index:99;}</style>");
}
</script>
By this we set our image, z-index and background to preloader class. Our cookie equals null only when user enter the site through domain name OR have cleared his cookie and refresh the page (which seems unlikely). And if cookie equals 1, as we set above, our preloader will show up but without picture and background, and our jQuery fadeOut will not run too! So, my problem resolved as I wanted, preloader will show up only once. Thanks again to @prabeen-giri!