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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.