Javascript setInterval and objects

There is a problem with javascript's setInterval method and objects.

Take a look at the following example:

function Text (message) {
  this.message = message;
  this.printMsg = printMsg;
  this.start = start;

function printMsg () {
  alert (this.message);

function start () {
  window.setInterval (this.printMsg, 5000);

function startMe() {
  var t = new Text("Reload the page to stop me");

Javascript Table filter

This is a simple but powerful javascript to filter a standard html table. The user enters a term in a text field and just the table entries which contain it will be shown.
function filter (term, _id, cellNr){
	var suche = term.value.toLowerCase();
	var table = document.getElementById(_id);
	var ele;
	for (var r = 1; r < table.rows.length; r++){
		ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g,"");
		if (ele.toLowerCase().indexOf(suche)>=0 )
			table.rows[r].style.display = '';
		else table.rows[r].style.display = 'none';
This function searches in the table with the id defined by _id in every row in the cell defined by cellNr. The search is case insensitive.
The usage is straightforward:
	<input name="filter" onkeyup="filter(this, 'sf', 1)" type="text">
It should work with all modern browsers, e.g. IE5, Firefox 1.0, Opera 7 and Mozilla 1.0.

Javascript Ajax Chat

This is a simple javascript chat, which uses XmlHttprequests or AJAX to get the new entries. Because of this it is responding very fast and you can talk to your friends nearly as comfortable as with IRC ;).
This is an old project of me and I do not plan to develop it any further, it was just a proof of concept. The chat supports smileys. If you are interested in the short and ugly source (Javascript and PHP) just drop me a line.

Auto complete javascript text field

This is a javascript example for an auto complete text field. You can use the mouse or the up and down keys to select an entry. By pressing escape you leave the suggestion box. It runs fine with Mozilla, IExplorer 5+6. It also works in opera, but it has some minor glitches.
Syndicate content