2

I have a html page which have a svg. I use Chrome 54.0.2840.98 (64-bit) as web browser in Mac OS.

The svg is displayed well with localhost, whereas it is not displayed when i specify file:///Users/softtimur/... in the browser path.

I have searched some threads, some suggested to change the page to xhtml, I did it. And make the header as follows:

<html xmlns="http://www.w3.org/1999/xhtml">
  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />

But the svg is still not shown in local.

Could anyone help?

PS: Here is the file. After downloading it, you may need to change the name test.xhtml.txt to test.xhtml.

Edit: This thread mentions that Chrome may block the access to local documents (Object in your case) from remote scripts (svg-pan-zoom). Is there a way that I rewrite the page to find a workaround? Or could I do something about Chrome settings? I really don't want to use localhost.

Community
  • 1
  • 1
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • Please show the entire file. Is it a XHTML file containing an element ? – Mr Lister Nov 28 '16 at 08:50
  • I just uploaded a file, please see OP. – SoftTimur Nov 28 '16 at 15:49
  • 1
    The uploaded file works fine if I have a D3 script available locally. i.e. have d3 file on the same folder and use ``. I also don't see that it loads any external resources that could cause a cross origin issue. I can see the svg object containing 3 dots with two arrows. If this isn't case, are there any errors from console log? – Chainat Nov 30 '16 at 06:11
  • Indeed... actually, `http://` should be added if we want to use the external `d3`. So by using ``, a html file without `` works already... Thank you... – SoftTimur Nov 30 '16 at 06:53

2 Answers2

3

As Chainat and I discovered (in comments), the key is to write <script src="http://d3js.org/d3.v3.min.js"></script> (over <script src="d3js.org/d3.v3.min.js"></script>) if one wants to use external d3. Then even a html file without <html xmlns="http://www.w3.org/1999/xhtml"><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> works...

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
-1

First of all.
SVG's Doctype will not start with html.
svg doctype is

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

Here is the link for "Doctype's" [https://www.w3.org/QA/2002/04/valid-dtd-list.html][1].

Could you conduct another test, like opening SVG file from folder, if windows then windows explorer, by double clicking the file. It should open in your default web browser.

I have not seen this when I open my files "file:///", instead I see Drive "C:/" like this.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
vssadineni
  • 454
  • 4
  • 11
  • Sorry, I forgot to mention that I use Mac OS... Double clicking the file in `Finder` does open the link in my default web browser (i.e., Chrome), and the svg is not shown. – SoftTimur Nov 28 '16 at 06:46