shadowayex Posted May 21, 2008 Share Posted May 21, 2008 Ok, I have a chatroom type of thing, and I want to have it run a function when a new message is sent. I tried onchange but it didn't do anything. What event would I need? Link to comment Share on other sites More sharing options...
Synook Posted May 21, 2008 Share Posted May 21, 2008 I would use onsubmit in conjunction with a form. Like what the script I gave you from "Chat box and IM system" has - you can just include other functions in the onsubmit handler. Link to comment Share on other sites More sharing options...
jeffman Posted May 21, 2008 Share Posted May 21, 2008 Then problem with onchange events in text elements is that the DOM only registers a change when the focus has changed. So simply adding characters is not enough. The user has to add characters and then click on some other element. I suppose this is to give the user the opportunity to change his/her mind. Okay, I guess that makes sense. Anyway, it makes onchange ambiguously useful for the kind of sitch you describe. Better to wait for the submit event itself. Psychologically speaking, I think that really is the only time at which you can say the user is committed to the new text, anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.