The code below

I have a problem... When you hit enter on a text field firefox stays at the same page because I have returned false; (I assume) but IE still submits the form normally.

What am I doing wrong?

window.onload = function() {
  var form = document.getElementById('keyword');
  var inputbox = document.getElementById('searchType');
  inputbox.onkeyup = function(e) {
    e = e || window.event;
    keycode = e.keyCode || e.which;
    if (keycode == 13) {
    	ajaxGet(form,'index.html'); //submit form AJAX
	return false; //supposedly to stop browser from submitting
    }else if(this.value.length > 2){
	showHint(this.value);
    	return;
}else{
       //return everything to normal
	var query = document.location.hash.replace('#','');
	query = query.replace(':q:','?');
	breadCrumbs(query);
	return;
	}
  }
};

solved it with a <form ... onsubmit="return false;" ... >

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.