javascript - How to run a function every 5 sec with difference value everytime? -
i try run notification message on page wondering there siimple ways code this?
<script> window.settimeout(function(){ izitoast.show({ hyperlink: '?id=002', title: 'title 2', message: 'message 2', image: 'img/2.jpg', timeout: 7500, }); }, 5000); window.settimeout(function(){ izitoast.show({ hyperlink: '?id=003', title: 'title 3', message: 'message 3', image: 'img/3.jpg', timeout: 7500, }); }, 17500); window.settimeout(function(){ izitoast.show({ hyperlink: '?id=004', title: 'title 4', message: 'message 4', image: 'img/4.jpg', timeout: 7500, }); }, 30000); window.settimeout(function(){ izitoast.show({ hyperlink: '?id=005', title: 'title 5', message: 'message 5', image: 'img/5.jpg', timeout: 7500, }); }, 42500); </script>
how can use simple code run function? sorry im new in programming , self learner.
i think need this
var = 0; var interval; //taken ma kobi answer var options = [ { hyperlink: '?id=002', title: 'title 2', message: 'message 2', image: 'img/2.jpg', timeout: 7500, }, { hyperlink: '?id=003', title: 'title 3', message: 'message 3', image: 'img/3.jpg', timeout: 7500, }, { hyperlink: '?id=004', title: 'title 4', message: 'message 4', image: 'img/4.jpg', timeout: 7500, }, { hyperlink: '?id=005', title: 'title 5', message: 'message 5', image: 'img/5.jpg', timeout: 7500, }]; //taken ma kobi answer function myfunction() { interval= setinterval(function () { izitoast.show(options[i]); i++; if (i == 6) { = 0; clearinterval(interval); } }, 1000); }
Comments
Post a Comment