Run Function Every X Seconds?
Jun 11, 2009I'm writing a script for a chatbox and I want to run the function to retrieve the messages from the .xml file every five seconds or so. How would I do that?
View 3 RepliesI'm writing a script for a chatbox and I want to run the function to retrieve the messages from the .xml file every five seconds or so. How would I do that?
View 3 RepliesI'm trying to write a script that will run a function every x many seconds. I'd have thought that there would be a function for this already, but I didnt find anything. So I wrote the following..
do{
now = new Date
seconds = now.getSeconds()
if(seconds+"2" == now.getSeconds()){
function();
}}
while(1)
Which didn't work.. just hung the browser. BTW 2 is the interval in seconds.
i want to copy gmail's auto save feature. i want to say 30 or so seconds after an onchange event, for it to call another function. i dont know how to do a timed event though and i was thinking that since the event happens over and over again as the user types, the 30 seconds would be restarted with every keystroke.
View 3 Replies View RelatedI want to make a function that will trigger another function 3 seconds after it is triggered.
Code:
<script type="text/javascript">
function Start(){
...function is here...
[Code]....
I was wondering if someone can help me write some jQuery that would be executed after 1.8 seconds pass. Well what I want to be executed is all div tags to be shown. As$(document).ready(function() {
("div").show();});would show all div tags when the document is loaded.Is there a way I could do something like what I have written inpseudo-code$(document).wait("1800", function() { ("div").show();});
I have a problem I can't figure out on my own. I want to create a JS/AJAX function which counts down for exactly 10 seconds (for example), and then it performs an action - calls a .php file, and loads its content in a div element.
The main problem is - users can simply edit the JS and set the 10 second timer to 1 second, for example.
I wonder if there is a way to work this out in JS? I want the 10 seconds to be "set in stone".
I guess I could achieve similar effect by using database, and comparing the time when script started/ended.
I have this function delayLoad()
function delayLoad()
{
setTimeout('window.open('test.swf','FacNews', 'width=303,height=757,left=1005,top=0')',3000);
}
test.swf is a flash file within the same folder. I am invoking this function using
<body onload="delayLoad()">
What am I doing wrong for this not to delay the load by three seconds? I am having a system login that spawns a child window so I need to delay the window load of the swf so that it is on top. Its been years since I've done javascript, is there some other kind of methodology that I could possibly use?
I currently have a bid of code:
(simplified)
$(function() {
$(window).bind('scroll',function(event) {[code]...
But I only need it to execute if the user hasn't scrolled for three seconds. I don't really have a clue how to go about this.
i found a script that starts counting seconds from 0 till x. i wanted it to display the seconds in mm:ss (minutes : seconds) .. now i only get "NaN:0" (NaN for minutes and 0 for seconds). this is how i ended up : [URL]
View 1 Replies View RelatedI need to get something fun! with setTimeout function!I am n00b! :D so be patent please.I need when <body onload="Myfunc();"> fires, that function should show "Please wait...!" or "Loading...". for , say 5 seconds!. then it disappear.I used setTimeout with that but it didn't do what I wanted!here is my code:
function Myfunc(){
document.getElementById("ss2").innerHTML = "Loading...";
setTimeout("Myfunc();", 5000);
[code]....
I need to develop this feature for a charity site displays a number that counts up 1 every 15 seconds. This is to show how many times a kid is abused in this country.
I figured this piece of code was a good start:
function doSomething() {
setTimeout('doSomething()',15000);
}
Could reorganize to make it a bit shorter, but. . .
//*******************************************************
//Convert seconds to HH:MM:SS
//*******************************************************
function convertHMS(sec)
{
//From JS FAQ by Liorean
Number.prototype.toDecimals=function(n){
n=(isNaN(n))?
2:
n;
var
nT=Math.pow(10,n);
function pad(s){
s=s||'.'
return (s.length>n)?
s:
pad(s+Ɔ');
}
return (isNaN(this))?
this:
(new String(
Math.round(this*nT)/nT
)).replace(/(.d*)?$/,pad);
}
if(sec>59)
{
var hrs=sec/3600;
if(hrs<0)
{
hrs="00";
var min=hrs*60;
min=min.toDecimals(8);
var snd=min.substring(min.indexOf('.'),min.length);
min=min.substring(Ɔ',min.indexOf('.'));
if(min<10)
{
min=Ɔ'+min
}
snd=Math.round(snd*60);
if(snd<10)
{
snd=Ɔ'+snd;
}
var tm=hrs+':'+min+':'+snd;
}
else
{
hrs=hrs.toDecimals(8);
var min=hrs.substring(hrs.indexOf('.'),hrs.length)
hrs=hrs.substring(Ɔ',hrs.indexOf('.'));
if(hrs<10)
{
hrs=Ɔ'+hrs;
}
min=min*60
min=min.toDecimals(8);
var snd=min.substring(min.indexOf('.'),min.length);
min=min.substring(Ɔ',min.indexOf('.'));
if(min<10)
{
min=Ɔ'+min
}
snd=Math.round(snd*60);
if(snd<10)
{
snd=Ɔ'+snd;
}
var tm=hrs+':'+min+':'+snd;
}
}
else
{
if(sec<10)
{
sec="0"+sec;
}
var tm="00:00:"+sec
}
return tm;
}
i have a form.. i validated it..if the form has an empty field, instead of popping up an alert box, i need to display a message that goes off say after 5 seconds..
View 1 Replies View RelatedI have some ad code in a smarty .tpl file that I want to refresh every 10 seconds so it will load a new ad. My ads are getting plenty of views but I want people to multilple ads in one page view instead of when the whole page is refreshed.
<div id="ads_refresh">
{if $ads->ad_top != ""}
</div>
All the code I have browsed on the web want to load an external file into a div instead of just refreshing the div with the content already in it.
I want to be able to hide a div ten seconds after clicking on a link.
View 24 Replies View Relatedi implement jquery tab in my new website but i have problem while page loading, when i first time open page it display random data without css for 2-3 second and then everything is ok, if anyone know the problem let me know[URL]...
View 1 Replies View RelatedAm having 5 images,
image1,image2 upto image5,
when the page is loaded initially i want to display image1 for 8second, then next 5second image2, next 5 seconds image3,next5 secondimage4,next5second image5,
then again i want to display imag1 for 8 second ...continue this loop,
Using java script i want to do this , any good suggestion for this,,
i have tried like set interval function. how to disable other image and how to call the images for 5sec,
We have a problem in our currently built website, in chrome+firefox the website works great but in IE 7+8+9 the javascript stops working after few seconds or after several commands a user do in the website.
The url is : [url]
How do i change an image every 3 seconds between 3 images and on a loop? What is the simplest way to do it?
View 3 Replies View RelatedI have a welcome message on my site and would like to automatically hide it after several seconds. I can't find anything usable after searching over the internet
View 2 Replies View RelatedThis is the script to hide the div (adsdiv)Its working on all browser except IE
<script type="text/javascript">
function closeMyAd() {
document.getElementById("adsdiv").style.display = "none" ;
[code]....
I found this code, written by Philip M on another thread [URL] of this forum:
<div id = "adsdiv">This ad will close in
<span id = "closingtimer">31</span>
seconds
</div>
<script type="text/javascript">
[Code].....
I need to reverse the script to show a div after 30 seconds, not to hide it.
I want a code that changes text (of maybe a div) after 10 seconds.
So like i could have some text and a link on my page then after 10 seconds it will change to something else and i can make it change to as many things as i want. Then when it goes threw them all it starts over.
topic has been answered
View 1 Replies View RelatedI am building a website, where I need a page to after a delay of five seconds upon load, automatically load a random url, from an array of a couple of different urls. Any idea how to do this ? I found something that does this, but without the 5 second delay..
<script type="text/javascript">
var urls = new Array();
urls[0] = "http://www.AAA.com";
urls[1] = "http://www.BBB.com";
urls[2] = "http://www.CCC.com";
[Code]...
I'm using dreamweaver and I'm looking for a script code for after sending a form (after submitting it), after 10 seconds the page jumps to an new URL.
View 2 Replies View Related