MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

SearchBoxEx, FireFox and the Enter Key Not Working

  Asked By: Jim    Date: Jan 26    Category: MOSS    Views: 1407

Having a problem with SearchBoxEx on our corporate site that's easy to reproduce.
1) Create an out-of-the-box Publishing Portal. No customizations required.

2) With FireFox 3, go to the home page of the new site. (I'm told that the problem also exists with FireFox 2, but I didn't personally verify.)

3) In the search box, enter a search phrase and press the enter key.

4) The home page simply refreshes instead of going to the search results page.

With IE 6/7 and Safari 3, everything works as expected. That is, the search results page is displayed.

I've reproduced this bug with three flavors of MOSS: MOSS RTM, with MOSS SP1 installed and finally with MOSS Infrastructure Update installed.

Looking at the traffic in Fiddler, it appears that *two* requests are being generated by FireFox. One to the search results page and one to the home page (in that order).

Anybody seen this before? I can't find any mention of it on the web. Short of creating my own SearchBoxEx or rewriting a bunch of MOSS JavaScript, is there an easy fix? The problem is not severe enough to justify a lot of effort. But it sure is annoying.



2 Answers Found

Answer #1    Answered By: Chelsey Watts     Answered On: Jan 26

thanks for taking the time to respond and confirming that I wasn't going nuts.

After searching around on the net, I found a site  (www.rotary.org) that solved the problem  with a clever JavaScript hack. If you look at the HTML source for the home  page, you'll see how they replace the function normally associated with the onkeypress event with a custom function in the event that the browser isn't IE. To see what I'm talking about, look at function replaceOnKeyPress().

To be sure, it's a hack because the server-generated names of the search  control and submit function are hard-wired into the function, but desperate times call for desperate measures, I guess.

Answer #2    Answered By: Nagesh Maulik     Answered On: Jan 26

Instead of hardwiring the ids into the code below is a modified function that will loop through the elements and find  the correct id for the mdlSearchBox:

<script type="text/javascript">

function replaceOnKeyPress()
var myid = '';
var mysubmitid = '';
var elem = document.forms['aspnetForm'].elements;

for(var i = 0; i < elem.length; i++)
if (elem[i].name.match("mdlSearchBox"))
myid = elem[i].id;

var myIdElements = new Array();
myIdElements = myid.split('_');

mysubmitid = myIdElements[myIdElements.length - 2];

var theFunction = mysubmitid + "_Submit();";
var theInputID = myid;

var txt = document.getElementById(theInputID);
var browser=navigator.appName;

if (txt && (browser == "Netscape"))
txt.onkeypress = function(e)
var key  = String.fromCharCode(e.keyCode);

if (key == "\n" || key == "\r")
return false;


Note that I placed this right before the closing form tag.

Didn't find what you were looking for? Find more on SearchBoxEx, FireFox and the Enter Key Not Working Or get search suggestion and latest updates.