为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Handling of Relative Attributes in Href

  • 4 个回答
  • 2 人有此问题
  • 4 次查看
  • 最后回复者为 wychegnome

more options

http://www.w3schools.com/tags/att_a_href.asp defines the attributes for urls that can be used with the href declaration in an anchor tag.

I have been using a relative attribute as set out in that definition within a web site in the form "<a href="ref-mt.html#006">MT006</a>" where the html file called is in the same directory on the web site as the page containing the call.

IE and Safari expand this call correctly to "http://www.s-r-s.org.uk/railref/ref-mt.html#006" and the link works as intended. Firefox does so as well when I use my local copy to test before uploading to the web site, BUT Firefox fails to expand correctly when working from the live web site. In these circumstances it expands the call to "http://www.s-r-s.org.uk/ref-mt.html#006" which does not work (page not found error) because the file is not in the root directory of the web site.

Interestingly if I alter the HTML code to <a href="../railref/ref-mt.html#006">MT006</a> Firefox does work correctly and, once that call is made it correctly expands all the other similar calls which remain in the form "<a href="ref-mt.html#006">MT006</a>".

Why does the expansion fail in this way?

http://www.w3schools.com/tags/att_a_href.asp defines the attributes for urls that can be used with the href declaration in an anchor tag. I have been using a relative attribute as set out in that definition within a web site in the form "<a href="ref-mt.html#006">MT006</a>" where the html file called is in the same directory on the web site as the page containing the call. IE and Safari expand this call correctly to "http://www.s-r-s.org.uk/railref/ref-mt.html#006" and the link works as intended. Firefox does so as well when I use my local copy to test before uploading to the web site, BUT Firefox fails to expand correctly when working from the live web site. In these circumstances it expands the call to "http://www.s-r-s.org.uk/ref-mt.html#006" which does not work (page not found error) because the file is not in the root directory of the web site. Interestingly if I alter the HTML code to <a href="../railref/ref-mt.html#006">MT006</a> Firefox does work correctly and, once that call is made it correctly expands all the other similar calls which remain in the form "<a href="ref-mt.html#006">MT006</a>". Why does the expansion fail in this way?

所有回复 (4)

more options

No problems here.

Reload web page(s) and bypass the cache.

  • Press and hold Shift and left-click the Reload button.
  • Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
  • Press "Cmd + Shift + R" (MAC)
more options

Thank you for responding cor-el.

I have since spotted some typos in my page railref.html and changing the \ to / in the railref.html page has resolved the matter - but still doesn't explain why Firefox didn't cope. IE and Safari didn't fall over on this and correctly expanded the links despite use of \ for / on the railref page.

more options

Firefox does not cope because it is not allowed according to webstandards. IE does not think that this is an error because backslashes are normal delimiters on the Windows platform, so they have a workaround for this.

more options

Thank you for the response.

It does seem that Safari also provides a 'work round'. I'm not sure they would have the same excuse as Microsoft though.