0

I have the below code filtering a library in sharepoint 2010.

<script src="http://www.google.com/jsapi"></script>

<script>


google.load("jquery", "1.2.6");

google.setOnLoadCallback(function() { 

$(document).ready(function()
{   
    jQuery.extend(jQuery.expr[':'], {
      containsIgnoreCase: "(a.textContent||a.innerText||jQuery(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0"
    });


    $("table.ms-listviewtable tr.ms-viewheadertr").each(function()
    {
        if($("td.ms-vh-group", this).size() > 0)
        {
            return; 
        }

        var tdset = "";

        var colIndex = 0;

        $(this).children("th,td").each(function()
        {
            if($(this).hasClass("ms-vh-icon"))
            {
                // attachment
                tdset += "<td></td>";
            }
            else
            {
                // filterable
                tdset += "<td><input type='text' class='vossers-filterfield' filtercolindex='" + colIndex + "' /></td>";                
            }

            colIndex++;
        });

        var tr = "<tr class='vossers-filterrow'>" + tdset + "</tr>";

        $(tr).insertAfter(this);
    }); 


    $("input.vossers-filterfield")
        .css("border", "1px solid #7f9db9")
        .css("width", "100%")
        .css("margin", "2px")
        .css("padding", "2px")
        .keyup(function()
        {           
            var inputClosure = this;

            if(window.VossersFilterTimeoutHandle)
            {
                clearTimeout(window.VossersFilterTimeoutHandle);
            }

            window.VossersFilterTimeoutHandle = setTimeout(function()
            {
                var filterValues = new Array();

                $("input.vossers-filterfield", $(inputClosure).parents("tr:first")).each(function()
                {               
                    if($(this).val() != "")             
                    {
                        filterValues[$(this).attr("filtercolindex")] = $(this).val();
                    }
                });     


                $(inputClosure).parents("tr.vossers-filterrow").nextAll("tr").each(function()
                {
                    var mismatch = false;

                    $(this).children("td").each(function(colIndex)
                    {
                        if(mismatch) return;

                        if(filterValues[colIndex])
                        {
                            var val = filterValues[colIndex];

                            // replace double quote character with 2 instances of itself
                            val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34));                         

                            if($(this).is(":not(:containsIgnoreCase('" + val + "'))"))
                            {
                                mismatch = true;
                            }                       
                        }
                    });

                    if(mismatch)
                    {
                        $(this).hide();
                    }
                    else
                    {
                        $(this).show();
                    }       
                });             

            }, 250);
        });
});

});

</script>

It does not work in firefox but works fine in internet explorer and I need to try and get it working in firefox. The script is an existing project from www.instantlistfilter.codeplex.com. I've been googling around and found a lot of mentions that it doesn't work in firefox but I haven't been able to find anything to get it to work in firefox. Any help getting this working in firefox would be greatly appreciated.

  • Is the site http or https? Have you checked Firefox console (F12)? – eirikb Jul 20 '17 at 7:45
3

Maybe just Firefox browser's cache issue, because otherwise your code would work. Try to make full request with Ctrl +F5. Use ctrl+shift+delete and clean the browser cache then run your code.

Or another issue might be: Your will not work randomly based on loading time/different browsers. Because Root cause of this is that you are loading jquery.min.js from googleapis. Third party domain resources will get low priority than the local domain resources. "document ready" function statements will be triggered once the local domain resources are loaded. That is why you get this error.

Permanent Solution: Put jquery.min.js file in your server and call it from your domain. this solution will work even if your page has load time issues and in any browser.

  • Thanks for that, I'll try that. The issue with Firefox isn't intermittant, the script is just always unresponsive and never works no matter how long you allow it to continue. I'll try this and let you know what happens, my thanks again for your time. – ScottG Jul 23 '17 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.