在 subsite/subfolder 上找不到 SVG href ID
SVG href ID is not found when being on a subsite/subfolder
本期涉及另一个主题:。
另请查看找到该问题解决方案的讨论。
我目前对该解决方案的问题是,当现在位于 example.net/about 之类的子站点时,我的 SVG 元素使用的所有 ID 都找不到了。所以我所有的文本路径都位于我地图上的 0,0 坐标上,而不是我给它们的特定路径。此外,SVG 图形不再位于正确的位置。但是在 example.net 上一切仍然正常!
让我们以下面的示例为例,它只是我的 500 个元素之一,而且只是 textpath 元素。这在 abc.net 上按预期工作,但在 abc 上。net/about 不再找到 ID:
<path id="text1" d="M1585.621635966945,...some long path..."></path>
<textPath xlink:href="#text1">Some Text</textPath>
这肯定有意义,因为在示例中。net/about#text1 没有这样的 ID。所以我在考虑更改 href url。在下文中,我将向您展示我尝试过的方法以及它是否适用于“page(example.net)”或“subpage(示例.net/about)":
<textPath xlink:href="#text1">Some Text</textPath>
页面 工作,子页面 不工作
<textPath xlink:href="http://example.net/#text1">Some Text</textPath>
页面 工作,子页面 不工作
<textPath xlink:href="http://example.net/text1">Some Text</textPath>
页面 不工作,子页面 不工作
<textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath>
页面不工作,子页面不工作
<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)/.*)$ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.html [L]
所以在 htaccess 中而不是在 index.html 中重写基础是可行的方法。上面的附加重写规则也确保在示例中。net/about/creator 你仍然可以找到正确的 css 等文件。
本期涉及另一个主题:
我目前对该解决方案的问题是,当现在位于 example.net/about 之类的子站点时,我的 SVG 元素使用的所有 ID 都找不到了。所以我所有的文本路径都位于我地图上的 0,0 坐标上,而不是我给它们的特定路径。此外,SVG 图形不再位于正确的位置。但是在 example.net 上一切仍然正常!
让我们以下面的示例为例,它只是我的 500 个元素之一,而且只是 textpath 元素。这在 abc.net 上按预期工作,但在 abc 上。net/about 不再找到 ID:
<path id="text1" d="M1585.621635966945,...some long path..."></path>
<textPath xlink:href="#text1">Some Text</textPath>
这肯定有意义,因为在示例中。net/about#text1 没有这样的 ID。所以我在考虑更改 href url。在下文中,我将向您展示我尝试过的方法以及它是否适用于“page(example.net)”或“subpage(示例.net/about)":
<textPath xlink:href="#text1">Some Text</textPath>
页面 工作,子页面 不工作<textPath xlink:href="http://example.net/#text1">Some Text</textPath>
页面 工作,子页面 不工作<textPath xlink:href="http://example.net/text1">Some Text</textPath>
页面 不工作,子页面 不工作<textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath>
页面不工作,子页面不工作<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)/.*)$ [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.html [L]
所以在 htaccess 中而不是在 index.html 中重写基础是可行的方法。上面的附加重写规则也确保在示例中。net/about/creator 你仍然可以找到正确的 css 等文件。