Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

setTImeout function not working in firefox

Featured Replies

Hi All,

 

Okay this ones bugging the hell out of me... the following code WORKS in I.E. and it even works in my friends Firefox browser... but on my own firefox browser, it runs init once and then refuses to repeat?

 

I have tried debugging it and have got it down to the point where its adding "xmlhttp.send();" that stops it.

 

If I remove that line then everything works fine??

 

 

Can anyone please give advice?

 

	




function init(){
			alert ("init");
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
			    var response = xmlhttp.responseText;
				if (response == "1"){
					loadInterface();
				}else{
				}	
		    }
		  }
	xmlhttp.open("GET","LiveAssistanceHandle.php?PickedUp=check&refresh=" + (new Date().getTime()),true);
	xmlhttp.send();
	setTimeout("init()",2000);

}


window.onload = init;

  • Author

checked it on brothers comp too which is firefox, and works fine for him too? Could this be something to do with browser version?

Something simple like this may solve your problem

 


setTimeout(function(){init();}, 2000);

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.