PDA

View Full Version : Delay the javascript function



drmutant2
01-02-2013, 06:44 PM
Hi,
I'd like to simply delay for 1 minute a JS function to execute. I have tried many times but no success, I am not good yet in syntax.
The function is a Fade-in image slideshow which works itself very well, the manual comes from here>

http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

(external files for js>
http://www.dynamicdrive.com/dynamicindex14/fadeslideshow.js
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js)

If someone just picks the piece of code and insert the delay function properly.) Thanks!

The page draft source>
http://www.pavelmartinek.com/2/index.html
http://www.pavelmartinek.com/2/styles/fadeslideshow.js
http://www.pavelmartinek.com/2/styles/screen.css

Nile
01-02-2013, 10:25 PM
You're going to need to provide a little bit more information. What about the slideshow do you want to delay? Or is this on a whole different issue?

Usually, without knowing specifically what you want, you'd use a timeout.


setTimeout(function() {

foo();

}, 1000 * 60); //1000 milliseconds/second * 60 seconds/minute

ajfmrf
01-02-2013, 11:39 PM
Please post a link to the problem page.

bernie1227
01-03-2013, 05:55 AM
Usually, without knowing specifically what you want, you'd use a timeout.

Or, you could use .delay() (http://api.jquery.com/delay/)

drmutant2
01-03-2013, 10:29 AM
Please post a link to the problem page.

The page draft is here..
http://pavelmartinek.com/2/index.html
http://pavelmartinek.com/2/styles/screen.css
http://pavelmartinek.com/2/styles/fadeslideshow.js

I simply want to delay the "fadeslideshow" function for 1 minute.

bernie1227
01-03-2013, 11:47 PM
Only thing I can really think to do is make this modification to the script:


$.holdReady(true);
setTimeout(function() {
$.holdReady(false);
}, 60000);

This should stop it working for 1 minute.

drmutant2
01-04-2013, 11:04 AM
Thanks but it doesn't work./

Put in fadeslideshow.js:


$.holdReady(true);
setTimeout(function() {
$.holdReady(false);
}, 60000);

var fadeSlideShow_descpanel={
controls: [['x.png',7,7], ['restore.png',10,11], ['loading.gif',54,55]], //full URL and dimensions of close, restore, and loading images
fontStyle: 'normal 11px Verdana', //font style for text descriptions
slidespeed: 200 //speed of description panel animation (in millisec)
}

jQuery.noConflict()

function fadeSlideShow(settingarg){

..........etc.


This doesn't work either:



setTimeout(function() {

foo();

}, 1000 * 60); //1000 milliseconds/second * 60 seconds/minute

var fadeSlideShow_descpanel={
controls: [['x.png',7,7], ['restore.png',10,11], ['loading.gif',54,55]], //full URL and dimensions of close, restore, and loading images
fontStyle: 'normal 11px Verdana', //font style for text descriptions
slidespeed: 200 //speed of description panel animation (in millisec)
}

jQuery.noConflict()

function fadeSlideShow(settingarg){

..........etc.


One more thing, during the delay period I'd like to have a background image in a browser which what I've found can't be managed by html.


#page {width:100%; height:100%; background-repeat: no-repeat; background-image: url(../img/1280-1024.jpg);}

jscheuer1
01-05-2013, 05:49 AM
You want to delay the start of the slideshow for 1 minute? If so, on the page replace:


<script type="text/javascript">
var mygallery=new fadeSlideShow({
wrapperid: "fadeshow1",
dimensions: [1280, 1024],
imagearray: [
["img/1.jpg"],
["img/2.jpg"],
["img/3.jpg"],
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false,
fadeduration: 500,
descreveal: "ondemand",
togglerid: ""
})
</script>

with:


<script type="text/javascript">
setTimeout(function(){
var mygallery=new fadeSlideShow({
wrapperid: "fadeshow1",
dimensions: [1280, 1024],
imagearray: [
["img/1.jpg"],
["img/2.jpg"],
["img/3.jpg"],
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false,
fadeduration: 500,
descreveal: "ondemand",
togglerid: ""
});
}, 60000);
</script>

drmutant2
01-05-2013, 06:17 PM
It works now! Thank you!