在子网站/子文件夹中找不到SVG href ID

SVG href ID is not found when being on a subsite/subfolder

本文关键字:SVG href ID 找不到 文件夹 网站      更新时间:2024-01-29

此问题涉及另一个主题:创建具有多个子文件夹链接的Ajax网站失败。还请查看在哪里找到该问题的解决方案的讨论情况。

我目前对该解决方案的问题是,当我现在在example.net/about这样的子网站上时,我的SVG元素使用的所有ID都找不到了。所以我所有的文本路径都位于地图上的0,0坐标上,而不是我给它们的特定路径。此外,SVG图形不再位于正确的位置。但是在example.net上,一切都很好!

让我们举下面的例子,它只是我的500个元素中的一个,只是textpath元素。这在abc.net上按预期工作,但在abc.net/上找不到关于ID的信息:

<path id="text1" d="M1585.621635966945,...some long path..."></path>
<textPath xlink:href="#text1">Some Text</textPath>

这当然是有道理的,因为在.net/about#text1上没有这样的ID。所以我在考虑更改href url。在下面的文章中,我向您展示了我的尝试,以及它是否适用于"页面(example.net)"或"子页面[example.net/about]":

  1. <textPath xlink:href="#text1">Some Text</textPath> 页面工作,子页面
  2. <textPath xlink:href="http://example.net/#text1">Some Text</textPath> 页面工作,子页面
  3. <textPath xlink:href="http://example.net/text1">Some Text</textPath> 页面不工作,子页面
  4. <textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath> 页面不工作,子页面
  5. <textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath> 页面不工作,子页面

我还在index.html头中设置了<base href="http://example.net">

那么,如何使用hashbang href方法将文本路径与SVG连接起来呢。

还有当前的htaccess

RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [L,QSA]

我现在想到的一个想法是设置window.location.pathname="/",但不幸的是,页面现在一直在重新加载。因此,告诉他一个不同的URL,即使使用另一个也不是真的可行。

这里还有非常有趣的文档:http://www.w3.org/TR/SVG/linking.html但无法从中找到解决方案。

这个运行良好:

RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(?:css|js|maps|pics) [NC]
RewriteRule (/(?:css|js|maps|pics)/.*)$ $1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.html [L]

因此,在htaccess中而不是在index.html中重写基是一种方法。上面额外的重写重用确保在example.net/about/creator上也能找到正确的css和so文件。