开发者

Get uri LocalPath in jquery/JS?

开发者 https://www.devze.com 2022-12-22 22:25 出处:网络
simple problem with a simple question. I have a string, in C# i can put it through a uri and access LocalPath

simple problem with a simple question. I have a string, in C# i can put it through a uri and access LocalPath

How do i get LocalPath in jquery or javascript? ( LocalPath: "/a开发者_C百科sas")

{http://z.com/asas?sadfdsgfg}

AbsolutePath: "/asas"
AbsoluteUri: "http://z.com/asas?sadfdsgfg"
Authority: "z.com"
DnsSafeHost: "z.com"
Fragment: ""
Host: "z.com"
HostNameType: Dns
IsAbsoluteUri: true
IsDefaultPort: true
IsFile: false
IsLoopback: false
IsUnc: false
LocalPath: "/asas"
OriginalString: "http://z.com/asas?sadfdsgfg"
PathAndQuery: "/asas?sadfdsgfg"
Port: 80
Query: "?sadfdsgfg"
Scheme: "http"
Segments: {string[2]}
UserEscaped: false
UserInfo: ""


Well, in the browser the "window.location" object has a "pathname" property, which is (I think) what you're asking for. There are other properties for the "protocol", "host", "port", etc: http://msdn.microsoft.com/en-us/library/ms952653.aspx

Now, that's the local path for the page you're working from; in other words, that's not a general-purpose way to get the local path for any old URL floating around in space.

0

精彩评论

暂无评论...
验证码 换一张
取 消