SoftTimur SoftTimur - 2 days ago 6
HTML Question

Make a html or xhtml page with svg displayed in local

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
.

Answer

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...

Comments