Use jQuery to find pathname of URL where default documents are used on the server and no filename is shown

StackOverflow https://stackoverflow.com/questions/8460406

  •  13-03-2021
  •  | 
  •  

Question

Is it possible to use jQuery to find the current url's filename (path) when a default document (or possibly mvc routing) is used and there is no filename in the address bar?

I am using jQuery to build a navigation system and I have it comparing the current URL to each nav item to determine if it is the selected item. I've seen a lot of answers about getting file info, but I haven't been able to get a difinitive answer if this is able to be done when there is no filename showing.

EXAMPLE: "www.mysite.com" -- this url/page could be: index.html, default.aspx, default.asp, index.htm, etc.

This is needed so I can see what nav link should be highlighted on the default page. Thanks.

Était-ce utile?

La solution

The information is just not available at all, jQuery or no jQuery. The site responds however it wants. Some might do an explicit redirect, I guess, but it's pretty hard (if possible at all) to track that client-side.

Of course, if you control the server, then your server can obviously instrument the outgoing pages however it wants.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top