Jump to content

2 function init() not working


dsp77

Recommended Posts

Hello,

I'm using 2 java scripts that use function init() {} and they don't work together, i'm not that good on js please advise me how to make them work together. There are the scripts:

window.onload = init;
var interval;
function init()
{
interval = setInterval(trackLogin,1000);
}
function trackLogin()
{
var xmlReq = false;
try {
xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlReq = false;
}
}
if (!xmlReq && typeof XMLHttpRequest != 'undefined') {
xmlReq = new XMLHttpRequest();
}

xmlReq.open('get', 'check.php', true);
xmlReq.setRequestHeader("Connection", "close");
xmlReq.send(null);
xmlReq.onreadystatechange = function(){
	if(xmlReq.readyState == 4 && xmlReq.status==200) {
		if(xmlReq.responseText == 1)
		{
			clearInterval(interval);
			alert('You have been logged out due to inactivity. You will now be redirected to home page.');
			document.location.href = "index.php";
		}
	}
}
}

and

		var clip = null;

	function init() {
		// setup single ZeroClipboard object for all our elements
		clip = new ZeroClipboard.Client();
		clip.setHandCursor( true );
		clip.addEventListener( 'complete', function(client, text) {
			alert("The password is now copied to your clipboard.");
		} );			
		// assign a common mouseover function for all elements using jQuery
		$('div.multiple').mouseover( function() {
			// set the clip text to our innerHTML
			clip.setText( this.innerHTML );

			// reposition the movie over our element
			// or create it if this is the first time
			if (clip.div) {
				clip.receiveEvent('mouseout', null);
				clip.reposition(this);
			}
			else clip.glue(this);

			// gotta force these events due to the Flash movie
			// moving all around.  This insures the CSS effects
			// are properly updated.
			clip.receiveEvent('mouseover', null);
		} );
	}

Link to comment
https://forums.phpfreaks.com/topic/224422-2-function-init-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.