gpt4 book ai didi

phoenix-framework - 如何获取 URL 的 #fragment 标识符部分

转载 作者:行者123 更新时间:2023-12-03 20:18:43 24 4
gpt4 key购买 nike

在 Phoenixframework 中,我想知道请求的完整 URL 路径,因此我尝试使用 <%= @conn.request_path %> .
问题是我要求:/spa.html#pageone而我只有 /spa.html .
获得 #fragment 的正确方法是什么?标识符的一部分呢?

最佳答案

该片段在服务器端不可用。
来自 RFC2396

When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.


您可以通过 window.location.hash 在 JavaScript 中访问它.
http://www.mikeduncan.com/?s=named+anchors (来自 Get anchor part of URL in controller in Ruby on Rails)是有关该主题的好资源。

关于phoenix-framework - 如何获取 URL 的 #fragment 标识符部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34687098/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com