(somewhat) Javascript Chatroom

S

Stuffman

I think it may be possible to make a chatroom entirely in Javascript.
Everything works fine, but it doesnt go out to the whole world. I'm
trying to fix this. Here's what i have so far:

Chat box:
<textarea readOnly
cols="26"
rows="5"
name="textfield">Welcome to (website) Chat!</textarea>

Post box:
<input type="text" name="chat"></input>

Submit button:
<input type="submit" name="Submit" value="Send"
onclick="if (guest.checked) textfield.value+=chat.value+=enter.value;
else textfield.value+=error.value+=enter.value
f('textfield')">

Scroll down code (textarea):
<script type="text/javascript">
function f(ta_id){
var d=document, ta, rng;
if(d.all){
ta=d.all[ta_id];
if(ta && ta.createTextRange){
rng=ta.createTextRange();
rng.collapse(false);
rng.select();
}
}


}


</script>

"Login as Guest" option (required for post):
<input type="checkbox" name="guest" onClick="var guest1=prompt('Enter
a guest username.'); alert('Logged in as Guest');
guest.disabled=this.checked">Login as Guest</input>

The rest of the code is just all of the things it needs to post
properly. Find a way to hide these from view. I used Microsoft Office
Publisher and covered it with an autoshape.

"Not logged in" message:
<input type="text" name="error" value="You are not logged in. Please
select the box above to login as a guest."></input>

Enter (seperates posts):
<textarea name="enter">

</textarea>




That's what I have so far. But one question: How can I gewt it to post
to the whole world? Any help?
 
V

VK

I think it may be possible to make a chatroom entirely in Javascript.

No, because you need a server-side program that will get messages and
store it in some file so others could re-read it to see new messages.
That's what I have so far. But one question: How can I gewt it to post
to the whole world? Any help?

It is not relevant to this group. What group is relevant depends on
what server you have your space (if any): ASP, PHP etc.
 
E

Evertjan.

VK wrote on 25 apr 2010 in comp.lang.javascript:
No, because you need a server-side program that will get messages and
store it in some file so others could re-read it to see new messages.


It is not relevant to this group. What group is relevant depends on
what server you have your space (if any): ASP, PHP etc.

Wrong answer.

This NG is not about clientside scripting,
but about the Javascript language.

A very simple working example on an ASP platform:

=============== miniChat.asp ================
<%@LANGUAGE = 'JavaScript'%>
<%
if (Request.form('t')=='cls')
Application('t') = '';
else if (Request.form('t')!='')
Application('t') += '<hr>'+Request.form('t');
%>

<pre>
<%= Application('t') %>
</pre>
<form method='post'>
<input name='t'>
<br><input type='submit' value='send or read'>
<br>Sending cls clears the screen
</form>
=========================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top