Mastering SharePoint

Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

Latest post Wed, Sep 3 2008 3:01 PM by AutoSponge. 15 replies.
  • Fri, Aug 29 2008 1:11 PM

    Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     

    Dear All,

    We have a SharePoint site in production with a scope limited to a single list for one of the searches. The scenario is like this:

    - We have 2 searches for the site
       (1) A scoped search for searching within the list
       (2) An advanced search for entire site.

    Now the searches works well with IE6 and IE7 both. However, I suddenly realized that it doesn't work for either of Firefox 2.0.1 or 3.0.1 and after pressing search button stays on the same page and doesn't goto results page. What could be the reason? I am giving page redirect using Javascript inside my content editor webpart. Please suggest. Here is some sample code:

     function doIdNumSearch() {
       var k = document.getElementById('my_list_idnum').value;
       var loc = 'results.aspx?k=' + k + ' contentclass:STS_ListItem_GenericList&s=my list'
       window.navigate(loc);
     }

    function doKeySearch() {
      if (event.keyCode == 13) {
        doIdNumSearch();
    }

    Please suggest.

    Filed under: ,
  • Fri, Aug 29 2008 1:40 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    Much of SP functionality doesn't work as it's supposed to outside of IE. Thanks MS for that.

    Are you using a customized master page?

    Chris Poteet
    Solutions Architect
    Mixon Consulting
    Blog

    Filed under: ,
  • Fri, Aug 29 2008 1:56 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     It is customized in the sense of changing logos and footer and navigation but it is taken from Blank site template with addition of the things above. One thing I checked was using Firebug to debug and I see the variables k and loc returning Null when I click on my search button.

    Thanks,

    Shell

  • Fri, Aug 29 2008 2:29 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    I think you need to use window.location.href instead of window.navigate.

  • Fri, Aug 29 2008 2:41 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     I tried window.location.href = loc it still doesn't work.

  • Fri, Aug 29 2008 3:05 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    This works in both browsers, check your ; at the end of your var too.

    <script type="text/javascript">
    function doIdNumSearch() {
       var k = document.getElementById('my_list_idnum').value;
       var loc = 'results.aspx?k=' + k + ' contentclass:STS_ListItem_GenericList&s=my list';
       window.location = (loc);
     }

    //-->
    </script>

    <a href="BLOCKED SCRIPTvoid(doIdNumSearch())">redirect</a>
    <div id="my_list_idnum">list</div>

     

    the "j a v a s c r i p t :" before the void doesn't show here because of filters.

  • Fri, Aug 29 2008 3:32 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     Interesting..............when I use the Firebug to debug and put a breakpoint at window.location, it redirects successfully. However, as I remove the breakpoint and run the code it doesn't redirect and clears the textbox. Here is the code:

    "<TABLE border="0">       
     <TR>
      <TD class="ms-advsrchHeadingText" colspan="2">
       <H3 class="ms-standardheader" style="font-size:1em">Search by number...</H3>
      </TD>
     </TR>
     <TR>
      <TD class="ms-advsrchText"><LABEL for="my_list_idnum"><B>Number</B>:</LABEL>
      </TD>
      <TD class="ms-advsrchText">
       <INPUT name="my_list_idum" type="text" maxlength="200" id="my_list_idnum" onkeypress="doSearch();if (event.keyCode == 13) { return false; }">
      </TD>
     </TR> 
     <TR>
      <TD></TD>
      <TD><BUTTON onclick="doIdNumSearch()">Search</BUTTON></TD>
     </TR>      
    </TABLE>

    <SCRIPT language="javascript">
    function doIdNumSearch() {
      var k = document.getElementById('my_list_idnum').value;
      var loc = 'results.aspx?k=' + k + ' contentclass:STS_ListItem_GenericList&s=my list'
      window.location = (loc);
    }

    function doSearch() {
      if (event.keyCode == 13) {
        doIdNumSearch();
      }
    }
    </SCRIPT>"

     

  • Fri, Aug 29 2008 3:37 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    You're still missing a ; after your var definition before the window.location

  • Fri, Aug 29 2008 3:48 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     That was my copy-paste mistake. It has the semicolon at the end. Here is the right copy:

    "<TABLE border="0">       
     <TR>
      <TD class="ms-advsrchHeadingText" colspan="2">
       <H3 class="ms-standardheader" style="font-size:1em">Search by number...</H3>
      </TD>
     </TR>
     <TR>
      <TD class="ms-advsrchText"><LABEL for="my_list_idnum"><B>Number</B>:</LABEL>
      </TD>
      <TD class="ms-advsrchText">
       <INPUT name="my_list_idnum" type="text" maxlength="200" id="my_list_idnum" onkeypress="doSearch();if (event.keyCode == 13) { return false; }">
      </TD>
     </TR> 
     <TR>
      <TD></TD>
      <TD><BUTTON onclick="doIdNumSearch()">Search</BUTTON></TD>
     </TR>      
    </TABLE>

    <SCRIPT language="javascript">
    function doIdNumSearch() {
      var k = document.getElementById('my_list_idnum').value;
      var loc = 'results.aspx?k=' + k + ' contentclass:STS_ListItem_GenericList&s=my list';
      window.location = (loc);
    }

    function doSearch() {
      if (event.keyCode == 13) {
        doIdNumSearch();
      }
    }
    </SCRIPT>"

  • Fri, Aug 29 2008 10:40 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    This was a lot harder to figure out than I originally thought.  There are several things happening in your script that highlight differences between FF and IE.  The keycode, redirect, events, etc.  I finally came up with this and I think it's what you want (although the loc string looks odd, maybe there's supposed to be a & after k?):

    <table border="0">
        <tr>
            <td class="ms-advsrchHeadingText" colspan="2">
                <h3 class="ms-standardheader" style="font-size: 1em">
                    Search by number...</h3>
            </td>
        </tr>
        <tr>
            <td class="ms-advsrchText">
                <label for="my_list_idnum">
                    <b>Number</b>:</label>
            </td>
            <td class="ms-advsrchText">
                <input name="my_list_idnum" type="text" maxlength="200" id="my_list_idnum" onkeypress="return killEnter(event);" onkeyup="doSearch(event);">
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <input type="button" value="Search" onclick="doIdNumSearch();" />
            </td>
        </tr>
    </table>

    <script type="text/javascript">
    function doIdNumSearch() {
      var k = document.getElementById('my_list_idnum').value;
      var loc = 'results.aspx?k=' + k + 'contentclass:STS_ListItem_GenericList&s=my list';
      window.location = loc;
    }

    function doSearch(e) {              //must fire on keyup because of IE
        var characterCode;
        if(e && e.which){          
        e = e;
        characterCode = e.which;        //for most browsers
        }else{
        e = event;
        characterCode = e.keyCode;      //for IE
        }
        if(characterCode == 13){
        doIdNumSearch();
      }
    }

    function killEnter(e){                      //this stops IE from auto-submitting on ENTER
        if(e.keyCode == 13 || e.which == 13){
        return false;
        }
      return true;
    }
    </script>



  • Tue, Sep 2 2008 10:57 AM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     Hi,

    Thanks a lot for providing me the code above. I tried that and it is now not working in IE too!!! It gives some script error when I use the code above. Also, I tried after applying this code in FF, still with same result and DOESN'T work still.......

    I also think that this has not to do with event at this moment of time. Because when I click on the button to do search it still doesn't work.

    Thanks.

  • Tue, Sep 2 2008 11:56 AM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    I'm not sure what you're doing.  I tried it in both browsers and it worked fine.  If it's not hitting a page, it's probably because of this:

    var loc = 'results.aspx?k=' + k + 'contentclass:STS_ListItem_GenericList&s=my list';

    I don't know what that string is supposed to look like.  But the script properly builds the string in both browsers.

    Thanks,

    Paul

  • Tue, Sep 2 2008 2:41 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     Hi,

    The string is built so that it can target only my list and not any other area of the site for searching and bring results back from one list only. I tried to debug in FF and when I do "Step Into" at redirect function it works as a jem! However, as soon as I turn off the debug mode in FF and try to do the same it comes back to the same page again!

    This looks very weird to me........

    Thanks,

    Shell

  • Tue, Sep 2 2008 8:02 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

    Seriously,

    I tested it again, just copied the script above and pasted it onto my page.  It works in FF, IE, and now Google Chrome.  I get strings that point to nothing, but it's the right string per your variable concatenation:

    "http://mysite/Pages/results.aspx?k=44contentclass:STS_ListItem_GenericList&s=my%20list"

    To me, there's something wrong with the way you're building the string *shrug* but the script works in every browser that matters to date.

    Good Luck,

    Paul

  • Wed, Sep 3 2008 2:57 PM In reply to

    Re: Scoped search doesn't work in FireFox 2.0.1 or 3.0.1

     Hi Paul,

    After rigorous testing and checking I created a script similar to yours which works for both FF and IE. Pasting the script below:

    However, a problem still remains, when I click on the button it still doesn't redirect :(. It redirects successfully to search results page when I press Enter but not when I click the button.

    "<TABLE border="0">       
     <TR>
      <TD class="ms-advsrchHeadingText" colspan="2">
       <H3 class="ms-standardheader" style="font-size:1em">Search by number...</H3>
      </TD>
     </TR>
     <TR>
      <TD class="ms-advsrchText"><LABEL for="my_list_idnum"><B>Number</B>:</LABEL>
      </TD>
      <TD class="ms-advsrchText">
       <INPUT name="my_list_idnum" type="text" maxlength="200" id="my_list_idnum" onkeypress="doSearch(event);if (event.keyCode == 13) { return false; }">
      </TD>
     </TR> 
     <TR>
      <TD></TD>
      <TD><BUTTON onclick="doIdNumSearch()">Search</BUTTON></TD>
     </TR>      
    </TABLE>

    <SCRIPT language="javascript">
    function doIdNumSearch() {
      var k = document.getElementById('my_list_idnum').value;
      var loc = 'results.aspx?k=' + k + ' contentclass:STS_ListItem_GenericList&s=my list';
      window.location = loc;
    }

    function doSearch(e) {
      var charCode;
      if(e && e.which) {
       e=e;
       charCode = e.which;
      }
      else {
       e = event;
       charCode = e.keyCode;
      }
      if (charCode == 13) {
        doIdNumSearch();
      }
    }
    </SCRIPT>"

Page 1 of 2 (16 items) 1 2 Next > | RSS
Copyright (c) 2008 Mixon Consulting, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems