-2

I am trying to use D3 library within an ASP.NET web forms application. The app works fine in Google Chrome but throws an error in IE 11.

Default.aspx Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="d3.v4.min.js"></script>
    <!-- https://d3js.org/d3.v4.min.js -->
</head>
<body>
    <div>Hello World! </div>
    <script> alert(d3.select("div").text()); </script>
</body>
</html>

Error: JavaScript runtime error: 'd3' is undefined

Do I need any additional libraries to make it work in IE11?

developer
  • 1,401
  • 4
  • 28
  • 73

1 Answers1

1

IT may be security restrictions that prevent IE browser from downloading the D3 script. What you can do is to download the scripts, place them in the same folder as your files and change the referenced paths in your source.

I downloaded the d3.js file to my ASP.NET project from your reference and add it to the page.

I had tested it with IE 11 and it is working fine without any error.

Reference:

d3 is not defined - ReferenceError

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • Thanks for your reply. I have d3.js file downloaded and referenced locally but it throws the same error. Given that it is working on your IE 11, it looks like it seems to be some IE restriction issue (set by my organisation). Not sure how to solve this issue though. – developer Oct 07 '19 at 09:13
  • Did you added the script file in your ASP.NET project from an option called 'add existing' item? If not, please try to add like that and than try to reference in your page. – Deepak-MSFT Oct 07 '19 at 09:22
  • Yes, I did it already but no luck, It is working in Chrome so I think the code is correct. It seems to be a browser issue. – developer Oct 07 '19 at 09:31
  • If you are available with any other machine outside your work environment than you can make a test on that machine to check whether it is working or not. It can help to narrow down the issue. – Deepak-MSFT Oct 07 '19 at 09:33
  • Yes, I will give a try. Thanks for your help. – developer Oct 07 '19 at 11:10