•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,945 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1024 | Replies: 5
![]() |
•
•
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation:
Rep Power: 30
Solved Threads: 268
i think its a php script maybe
i know nothing about web design though so take that with a pinch of salt
i know nothing about web design though so take that with a pinch of salt
Last edited by jbennet : Jan 16th, 2007 at 2:22 am.
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
james.bennet1@ntlworld.com
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,889
Reputation:
Rep Power: 32
Solved Threads: 109
It's not possible to do this with JavaScript because you would need some sort of database to keep track of how many visitors there are, which can only be done with a server-side programming language.
We do it with PHP and MySQL. Each time a page is accessed, a record in a MySQL table is updated with the user's IP address and the timestamp. Records with timestamps older than 20 minutes are deleted. The number of IP addresses is the number of people currently visiting the site.
We do it with PHP and MySQL. Each time a page is accessed, a record in a MySQL table is updated with the user's IP address and the timestamp. Records with timestamps older than 20 minutes are deleted. The number of IP addresses is the number of people currently visiting the site.
Last edited by cscgal : Jan 16th, 2007 at 3:24 am. Reason: Typo
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
ok Thanks again. I found a similar code that may need slight tweaking to work for me. I dont have a 'veiws' cell on my main index though.
could I rewrite this to add to cell 'Forum'? which list the forum name?
P.s Im aware of the advertising ban so I wont link you my site to see.
p.s My templet for board index forum row. Where I have 'New topic' link is where I want Users Browsing
p.s users browsing [forum/topic] is written in php my board
could I rewrite this to add to cell 'Forum'? which list the forum name?
P.s Im aware of the advertising ban so I wont link you my site to see.
<script type="text/javascript">
<!--
/*
Users Viewing In Main Page
*/
var addrequest;
var viewadds = new Array();
var curnum = 0;
var td = document.getElementsByTagName('td');
for(t=0;t<td.length;t++){
if(td[t].getElementsByTagName('a')[0] && td[t].getElementsByTagName('a')[0].href.match(/showforum=\d+/)){
viewadds.push(td[t]);
}}
checkBViews();
function checkBViews(){
if(window.ActiveXObject){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();
}
var opener = viewadds[curnum].getElementsByTagName('a')[0].href;
addrequest.onreadystatechange = function(){
addBViews();
}
addrequest.open("GET",opener,true);
addrequest.send('');
}
function addBViews(){
if(addrequest.readyState == 4 && addrequest.status == 200){
var resptext = addrequest.responseText;
var addiv = document.createElement('div');
addiv.innerHTML = resptext;
var hdiv = addiv.getElementsByTagName('div');
var views = 0;
for(a=0;a<hdiv.length;a++){
if(hdiv[a].className == "darkrow2" && hdiv[a].innerHTML.match(/^(\d+) User\(s\) are browsing this forum/)){
views = parseInt(RegExp.$1) - 1;
}}
if(views < 0){
views = 0;
}
if(views != 0){
var viewstext = document.createTextNode( ' ('+views+' viewing'+')');
viewadds[curnum].insertBefore(viewstext,viewadds[curnum].getElementsByTagName('br')[0]);
}
curnum++;
if(curnum != viewadds.length){
checkBViews();
} else {
termViews();
}}}
function termViews(){
if(window.ActiveXObject){
addrequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
addrequest = new XMLHttpRequest();
}
addrequest.open("GET",location.href,true);
addrequest.send('');
}
//-->
</script>p.s My templet for board index forum row. Where I have 'New topic' link is where I want Users Browsing
<tr>
<td class="row4" align="center">{$info['img_new_post']}</td>
<td class="row4"><a href="{ibf.script_url}showforum={$info['id'] }"onMouseover="ddrivetip('Open This Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><b>{$info['name']}</b></a><br /><br><a href="{ibf.script_url}act=Post&CODE=00&f={$info['id']}"onMouseover="ddrivetip('Start A new Topic In this Forum!','yellow', 150)";
onMouseout="hideddrivetip()"><FONT COLOR="#FF0000"><b>New Topic</b></font></a><br /><br><span class='desc'>{$info['description']}<br />
</span></td>
<td class="row2" align="center">{$info['topics']}</td>
<td class="row2" align="center">{$info['posts']}</td>
<td class="row2" nowrap="nowrap">{$info['last_post']}<br />{ibf.lang.in}: {$info['last_unread']}{$info['last_topic']}
<br />{ibf.lang.by}: {$info['last_poster']}
</td>
</tr>p.s users browsing [forum/topic] is written in php my board
Last edited by Inny : Jan 16th, 2007 at 3:33 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation ajax api asp blogger blogging blogs code combo dani daniweb data debugging developer development dreamweaver dropdownlist firefox gdata google gpl home html innovation internet javascript key linux microsoft module msdn net news office openbsd product programming reuse rss serial site software source sql tags vista web wysiwyg xml
- Code tags whine-a-thon (DaniWeb Community Feedback)
- Problem with a Code Snippets present in (DaniWeb Community Feedback)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: IE problem - Something's wrong with this JS
- Next Thread: dynamically filling dropdown from another dropdown



Linear Mode