[英]How to use the URL filepath as parameters in plain html/javascript?
I know about setting and getting URL parameters, eg example.com/index.html?x=foo&y=bar&z=hello
would give your javascript access to the x
, y
, and z
variables specified in the URL. I know about setting and getting URL parameters, eg
example.com/index.html?x=foo&y=bar&z=hello
would give your javascript access to the x
, y
, and z
variables specified in the URL.
What I wish for is the same behavior but utilizing the file path part of the URL.我希望的是相同的行为,但使用 URL 的文件路径部分。 Eg
example.com/index.html/foo/bar/hello
.例如
example.com/index.html/foo/bar/hello
。
How can I accomplish this?我怎样才能做到这一点? In particular,
尤其是,
index.html
even though the file path index.html/foo/bar/hello
was specified?index.html/foo/bar/hello
,如何确保浏览器知道 go 到index.html
?example.com/index.html/foo/bar/world
, such that if I press "Back" on the browser, it will go back to example.com/index.html/foo/bar/hello
.example.com/index.html/foo/bar/world
,这样如果我在浏览器上按“返回”,它将 go 返回example.com/index.html/foo/bar/hello
。 Furthermore, I'd heavily prefer if the solution was in pure javascript/html, without reliance on jquery or any other libraries.此外,如果解决方案是纯 javascript/html,而不依赖于 jquery 或任何其他库,我会非常喜欢。
There's 2 scenarios you should handle.您应该处理两种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.