Jump to content

colandy

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by colandy

  1. Nah.......found the solution though adiv.onclick=function(e) { x=e.clientX; y=e.clientY; } works in Firefox but not IE so have to check browser type then code accordingly. However I now have another issue. As the adiv is created within a loop (a list of members on a chat) using this method all links get the same link. Heres the code: for(var i=0;i<messages.length;i++) { usrname=messages[(messages.length-1)-i]; if(navigator.appName=="Microsoft Internet Explorer") { var cdiv=document.createElement('<div id="user">'); var adiv=document.createElement('<a href="#" onclick="showpopup(event, \''+usrname+'\')">'); adiv.appendChild(document.createTextNode(messages[(messages.length-1)-i])); cdiv.appendChild(adiv); } else { var cdiv=document.createElement('div'); cdiv.setAttribute("id", "user"); var adiv=document.createElement('a'); adiv.setAttribute('href','#'); adiv.onclick=function(e) { x=e.clientX; y=e.clientY; showpopup1(x,y,usrname); } adiv.appendChild(document.createTextNode(messages[(messages.length-1)-i])); cdiv.appendChild(adiv); } mdiv.appendChild(cdiv); } OK, when I have 1 member online both IE and Firefox report the X & Y position correctly and the username too. However, when 2 or more users online, X & Y positions are reported correctly on both and the username that was clicked on in IE is reported correctly, Firefox always reports the last listed user regardless of which you click on. example firefox: guest999 - reports guest000 guest000 - reports guest000 example IE guest999 - reports guest999 guest000 - reports guest000 Any idea's...?!?!?!? PS - The showpopup functions just display an alert box show X co-ords, Y co-ords and username passed to it.
  2. I have the following code that creates a div and a link within that div, when the user clicks on the link the script should run a function which calculates the position of the mouse pointer. In IE this works fine, however in Firefox I get an error relating to the event object. I have read that Firefox has an issue with the event object and using it this way. var cdiv=document.createElement('div'); cdiv.setAttribute("id", "user"); var adiv=document.createElement('a'); adiv.setAttribute('href','#'); adiv.onclick=function() { var x=event.clientX; var y=event.clientY; alert("X - "+x+", Y - "+y); } adiv.appendChild(document.createTextNode(messages[(messages.length-1)-i])); cdiv.appendChild(adiv); Anyone got any idea's / Solutions...?!?!?!?!? Please
  3. Yippee !!!!!!!!......Many thanks, thought this was something I'd tried b4 but obviously got something wrong last time. Works a treat now.
  4. I don't see that your doing anything at all with the AJAX returned responseText. I also use AJAX as an object ....... var testObj = new AJAXFunction() Here you appear to be using a function, creating the object inside the function and then doin not a lot with it, there's no check after the send only b4 so I'm assuming that it returns nothing. You don't use contact_id at all even though it's set at the beginning. Just a few suggestions, hope they help
  5. I see no getChat text function. However, I had a similar issue with my chat app, the only way I found was to set the timeout after getting both the chat messages and the users online. Here's the code, still a work in progress but you should get the idea: function newGet() { // Get Chat Message Data var recObj= new ajaxObject('getchatdata.php', displayChatData); recObj.update(); // Get List of Users Currently using Chat var usrObj = new ajaxObject('getuserlist.php', displayUserData); usrObj.update(); //Re-Check every 2 seconds setTimeout('newGet()',2*1000); } function newSend() { var sndObj= new ajaxObject('sendchatdata.php', displayChatData); var userid='<?php echo $_SESSION["user_id"]?>'; var msg=document.getElementById('message').value; if(msg.length>100){msg=msg.substring(0,100)}; var message=('user='+userid+'&message='+msg); document.getElementById('message').value = ""; sndObj.update(message,'POST'); } function displayChatData(responseText, responseStatus){ if(responseStatus==200) { var mdiv=document.getElementById('chatwindow'); if(!mdiv){return}; var messages=responseText.split('|'); // display messages } } function displayUserData(responseText, responseStatus){ if(responseStatus==200) { var mdiv=document.getElementById('userContainer'); if(!mdiv){return}; mdiv.innerHTML=''; var messages=responseText.split('|'); // display messages } } function intitializeChat() { if(blah blah blah) { newGet(); } } The getUserList.php file woulld have to check which users have posted in the last 2 mins. But y not display all users within the chat. Easily done, as every time you check for message and users you can write to a db file using a timestamp, all records that are older than 5 seconds are for users that have left, as we update every 2 seconds.
  6. I have an AJAX Chat app running and the acompanying javascript calls the the AJAX object very 2 seconds, however I now need to run another object within the same web page that calls the new AJAX object every 5 seconds while still calling the old Object every 2. Any ideas...... I have copied the code here to give you an idea....... function newGet() { // Get Data var recObj= new ajaxObject('somefile.php', displaysomeData); recObj.update(); //Re-Check every 2 seconds setTimeout('newGet()',2*1000); } function intitializeApp() { if(blahblahblah) { newGet(); } } window.onload=intitializeApp; OK, so now I want to run another function like newGet, but have the timeout set to a diff interval
  7. Hi, My understanding is that if the session start is not at the beginning of the page the session data is lost. I usually ensure that this is part of every page on a web that uses sessions, therefore I know I won't lose any session data. I have recently started using AJAX for a chat app that I'm writting and don't get an issue using sessions this way.
×
×
  • 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.