简体   繁体   English

页面完全加载后启动滑块

[英]Slider to start after page had fully loaded

Is there a way to start the full screen slider on my site after the preloader (query loader 2) has finished loading? 在预加载程序(查询加载程序2)完成加载后,是否可以在我的网站上启动全屏滑块?

At the minute the preloader loads the page but once it has finished the slider is already half way through its first slide. 预加载器会在第一分钟加载页面,但是一旦完成,滑块就已经到达其第一张幻灯片的一半。 What I would like is for the preloader to finish loading then the slider to start. 我想要的是让预加载器完成加载,然后启动滑块。 Things I have tried: 我尝试过的事情:

1.) Changing the load order by adding the call to query loader to the top of the page and putting the slider call at the bottom of the page. 1.)通过将对查询加载程序的调用添加到页面顶部,并将滑块调用置于页面底部,来更改加载顺序。

2.) jQuery.getScript() which loaded the scripts in order but the slider had already started before the preloader had finished. 2.) jQuery.getScript()按顺序加载了脚本,但是滑块在预加载器完成之前已经启动。 I tried document.ready() on the slider but this loaded it the same time as the preloader. 我在滑块上尝试了document.ready() ,但这与预加载器同时加载了它。

If you have any ideas as to where I'm going wrong here your help would be much appreciated. 如果您对我在哪里出错有任何想法,将非常感谢您的帮助。

I have put a link to my site as I didn't know which piece of code to add on here http://stavriaphotography.com 我已经链接到我的网站,因为我不知道要在此处添加哪段代码http://stavriaphotography.com

you can try setTimeout function of javascript. 您可以尝试使用JavaScript的setTimeout函数。

setTimeout(function(){
    // your script code
},1000);

you can change 1000 by your specific time limit after which you want to load your script. 您可以按特定的时间限制更改1000,然后再加载脚本。

It's quite simple to make a function to check whether something has loaded. 创建一个函数来检查是否已加载东西非常简单。 At a boolean to the function named 'loaded' and set its value to false. 将布尔值命名为“ loaded”,并将其值设置为false。 At the end of the preloader set its value to true. 在预加载器的末尾,将其值设置为true。 Then to start your slider, check whether loaded is true and if so: start the slider. 然后,要启动滑块,请检查load是否为true,如果是,则:启动滑块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM