在子网站/子文件夹是时,SVG HREF ID未找到 [英] SVG href ID is not found when being on a subsite/subfolder

查看:210
本文介绍了在子网站/子文件夹是时,SVG HREF ID未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是关于另一个主题:<一href="http://stackoverflow.com/questions/28593650/creating-ajax-website-with-links-of-multiple-subfolders-is-failing/">Creating阿贾克斯的网站与多个子文件夹的链接失败。 也请看看到那里发现了这一问题的解决方案进行讨论。

This issue is concerning another topic: Creating Ajax website with links of multiple subfolders is failing. Please also have a look into the discussion where the solution for that issue was found.

我现在的问题与解决办法是,当现在正在像一个子网站的 example.net/about 所有使用我的SVG元素的ID不再被发现。所以我所有的textpathes都位于在我的地图,而不是我给他们的具体路径的0,0坐标。此外SVG图形不位于正确的位置了。但作为在 example.net 一切仍然工作正常!

My current issue with that solution is that when now being on a subsite like example.net/about all the ID's used by my SVG elements are not found anymore. So all my textpathes are located on the 0,0 coordinates on my map instead of the specific path I gave to them. Also SVG graphics are not located on the right place anymore. But being on example.net everything is still working fine!

现在,让我们看看下面的例子这仅仅是我的500的元素,只是在textpath要素之一。这是工作的预期abc.net但abc.net/about的ID不再被找到:

So let's take the following example which is just one of my 500 elements and just the textpath elements. This is working as expected on abc.net but on abc.net/about the ID is not found anymore:

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

这是肯定的有一定道理,因为在example.net/about#text1没有这样的ID。所以,我在想改变在href URL。在下面我会告诉你我尝试了,如果它的工作的(example.net)或子页(example.net/about):

That for sure does make sense because on example.net/about#text1 there is not such an ID. So I was thinking about changing the href url. In the following I show you what I tried out and if it worked on "page(example.net)" or "subpage(example.net/about)":

  1. &LT; textPath XLink的:HREF =#text1中的&GT;有的文字&lt; / textPath&GT; 工作子页不工作
  2. &LT; textPath XLink的:HREF =htt​​p://example.net/#text1&GT;有的文字&lt; / textPath&GT; 工作子页不工作
  3. &LT; textPath XLink的:HREF =htt​​p://example.net/text1&GT;有的文字&lt; / textPath&GT; 不工作,子页不工作
  4. &LT; textPath XLink的:HREF =htt​​p://example.net/index.html#text1&GT;有的文字&lt; / textPath&GT; 不工作,子页不工作
  5. &LT; textPath XLink的:HREF =htt​​p://example.net/index.html#text1&GT;有的文字&lt; / textPath&GT; 不工作,子页不工作
  1. <textPath xlink:href="#text1">Some Text</textPath> page working, subpage not working
  2. <textPath xlink:href="http://example.net/#text1">Some Text</textPath> page working, subpage not working
  3. <textPath xlink:href="http://example.net/text1">Some Text</textPath> page not working, subpage not working
  4. <textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath> page not working, subpage not working
  5. <textPath xlink:href="http://example.net/index.html#text1">Some Text</textPath> page not working, subpage not working

我也有&LT;基地的HREF =htt​​p://example.net&gt;在中的index.html头设置。

那么,如何可以使用连接textpathes与SVG的的hashbang HREF方式。

So how can I use the hashbang href way on connecting textpathes with SVG's.

同样,当前的htaccess

Also the current 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,即使使用其他是不是真的工作了。

One idea that came to my mind right now was to set window.location.pathname="/"but unfortunately the page is reloading all the time now. So telling him a different URL even though using another is not really working out.

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

Also very interesting docs here: http://www.w3.org/TR/SVG/linking.html but was not able find a solution from that.

推荐答案

这一个是工作的罚款:

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的是要走的路。上面的附加重写Reule烹制确保了也example.net/about/creator你还是找到正确的CSS等文件。

So rewriting the base in htaccess instead of in the index.html is the way to go. The additional rewrite reule above makes sure that also on example.net/about/creator you still find the correct css and so files.

这篇关于在子网站/子文件夹是时,SVG HREF ID未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆