bonjour,
j'ai intégrer un chat à mon blog
http://www.linuxuser.at/chat/index.html
Mais comme je n'y connais rien j'ai beaucoup de mal à personnaliser ses fonctions.
Dans un 1er temps je cherche à forcer la fenêtre du chat à afficher le dernier message pour ne pas avoir à descendre en permanence l'ascenseur
peut-être que le code suivant est un début de solution ?
Code js : Sélectionner tout - Visualiser dans une fenêtre à part var intElemScrollHeight = document.getElementById('id').scrollHeight;
si c'est le bon code (?) je ne sais pas ou l'utiliser non plus...
voici le javascript de mon chat:
si quelqu'un peut m'aider merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 <script type="text/javascript"> /**************************************************************** * Most Simple Ajax Chat Script (www.linuxuser.at) * * Version: 3.1 * * * * Author: Chris (chris[at]linuxuser.at) * * Contributors: Derek, BlueScreenJunky (http://forums.linuxuser.at/viewtopic.php?f=6&t=17) * * * Licence: GPLv2 * ****************************************************************/ /* Settings you might want to define */ var waittime=800; /* Internal Variables & Stuff */ document.getElementById("chatmsg"); /*chatmsg.focus()*/ document.getElementById("chatwindow").innerHTML = "chargement..."; var xmlhttp = false; var xmlhttp2 = false; /* Request for Reading the Chat Content */ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { document.getElementById("chatwindow").innerHTML = xmlhttp.responseText; zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('chat.txt?x=" + ms + "')", waittime) } } xmlhttp.open('GET',url,true); xmlhttp.send(null); } /* Request for Writing the Message */ function ajax_write(url){ if(window.XMLHttpRequest){ xmlhttp2=new XMLHttpRequest(); if(xmlhttp2.overrideMimeType){ xmlhttp2.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp2) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } xmlhttp2.open('GET',url,true); xmlhttp2.send(null); } /* Submit the Message */ function submit_msg(){ nick = document.getElementById("chatnick").value; msg = document.getElementById("chatmsg").value; if (nick == "") { check = prompt("please enter username:"); if (check === null) return 0; if (check == "") check = "anonymous"; document.getElementById("chatnick").value = check; nick = check; } document.getElementById("chatmsg").value = ""; ajax_write("chat.php?m=" + msg + "&n=" + nick); } /* Check if Enter is pressed */ function keyup(arg1) { if (arg1 == 13) submit_msg(); } /* Start the Requests! ;) */ var intUpdate = setTimeout("ajax_read('chat.txt')", waittime); </script>
++
Partager