Gravatar for ialmonte@harris.com

Question by ismael almonte, Oct 13, 2014 4:44 PM

REST JS Windows Authentication error on d3 script and IE 8

The d3.min.js script throws an error when using IE8. works fine on Chrome, firefox and IE9+.

Also works on IE8 if anonymous authentication is used instead of windows.

Error on: var d3formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3formatPrefix);

can't find map method.

also: htmlElement.style.width = labelMaxWidth.width - labelMaxWidth.crop + 'px';

It seems to be a known issue with the D3 library and IE8 because of missing HTML5 features.

http://stackoverflow.com/questions/17202118/d3-ie8-compatibility http://stackoverflow.com/questions/16828501/making-d3-js-compatible-with-ie8-ie9 https://github.com/shawnbot/aight

1 Reply
Gravatar for ialmonte@harris.com

Answer by ismael almonte, Oct 13, 2014 4:49 PM

I fixed it by using the aight library: https://github.com/shawnbot/aight

Steps

  1. Download the aight.js and aight.d3.js
  2. Add conditional includes for the 2 files in the Search.Html

Here's how it'll look:

  <!--[if lt IE 9]>
  <script type="text/javascript" src="myJs/aight.js"></script>
  <![endif]-->
  <script src="js/CoveoJsSearch.Dependencies.js"></script>
  <script src="js/CoveoJsSearch.js"></script>
  <script src="js/d3.js"></script>
  <!--[if lt IE 9]>
  <script src="myJs/aight.d3.js"></script>
  <![endif]-->
  <script src='templates/generated.js'></script>
  <link rel="stylesheet" href="css/CoveoFullSearch.css" />

Also, had to suppress an error on the aight.js line 1672 (listener.call(target, event);), which I could fix it but the search seems to be fine even suppressing the error: Change

listener.call(target, event);

For:

//suppressing error
try
{
    listener.call(target, event);
}catch(e)
{
if(window.console)
{
    window.console.log('Error aight(addEventListener,listener.call) Posible IE8: ' + e.message);
}
}
Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Oct 13, 2014 5:42 PM

Interesting info! Our official position regarding D3 and IE8 was that it isn't supported. We might want to revisit that.

NOTE: You only need to include d3.js when using the FacetRange component (it's used for the distribution graph). Most search pages don't use this component and in this case you can just remove that particular script from the page. But yes, the default sample page does reference it.

Gravatar for ialmonte@harris.com

Comment by ismael almonte, Oct 14, 2014 8:10 AM

More info,

The first thing I did was remove the range facet but did not know that the d3 could be removed.

I was getting the error only with REST windows authentication, if I enabled anonymous guest on the REST API service I did not get an error on IE8.

I would say that the standard JS demo htmls should be as bare as possible, if the d3 is not needed for regular facets then you guys should create a demo with the d3 range facet and one without. that way new users download the clean (without) version.

At least put a note on the documentation for the download page.

Ask a question