dsp77 Posted January 14, 2011 Share Posted January 14, 2011 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); } ); } Quote Link to comment https://forums.phpfreaks.com/topic/224422-2-function-init-not-working/ Share on other sites More sharing options...
RichardRotterdam Posted January 14, 2011 Share Posted January 14, 2011 I'm not too sure if it's a javascript or a common sense issue. What about rename one of the init functions to something else? Quote Link to comment https://forums.phpfreaks.com/topic/224422-2-function-init-not-working/#findComment-1159336 Share on other sites More sharing options...
Maq Posted January 14, 2011 Share Posted January 14, 2011 If you have 2 functions named the same thing, how do you expect javascript knows which one to use. Like Dj Kat said, rename one and see what happens. Does firebug give you an error? Quote Link to comment https://forums.phpfreaks.com/topic/224422-2-function-init-not-working/#findComment-1159460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.