Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
181
rated 0 times [  183] [ 2]  / answers: 1 / hits: 26104  / 11 Years ago, fri, july 19, 2013, 12:00:00

I need to get url on server middleware (using express.js). I use req.url but when url starts from /#some/url req.url returns /...



The same with req.path..



Is there a way to get url after # in express.js?


More From » url

 Answers
7

No. The part of the URL starting with the # symbol is never sent to the server.



The # symbol in an URL is to introduce the fragment identifier. This is used to link to a specific part of the page. If a browser loads /#some/url, it will effectively load /, and skip to the HTML element with id=some/url (if present). The fragment identifier is only relevant to the browser, so it is not sent with the HTTP request.



What you however can do, is using client side Javascript to read out the value of window.location.hash and send it to the server using an XMLHttpRequest. (See other Stack Overflow post.)


[#76881] Thursday, July 18, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
analiseg

Total Points: 460
Total Questions: 96
Total Answers: 90

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;