do browsers remove # in URL automatically?

前端 未结 5 2064
悲哀的现实
悲哀的现实 2021-01-06 19:22

our front end guy needs to form a url containing the hash, (i.e, http://blah/#some-link.) when we hit this on the browser and inspect the http traffic using fiddler, we saw

相关标签:
5条回答
  • 2021-01-06 19:35

    Hashmark is removed from URL when the back button is clicked in IE9, IE10 or IE11

    In IE10 , first time on clicking the HREF link leads to the correct below url: http://www.example.com/yy/zz/ff/paul.html#20007_14

    If back button is clicked again the, then it comes to the below url: http://www.example.com/yy/zz/ff/paul.html

    Solution :

    Please change the url with https

    It works for me

    0 讨论(0)
  • 2021-01-06 19:40

    The part of the URI including and after the hash (#) is never sent to the server as part of the HTTP request.

    The reason is that the hash identifier was originally designed to point at references within the given web page and not to new resources on the server.

    If you want to get the hash identifier, you'll have to use some client-side JavaScript to grab the value and submit it with the form.

    0 讨论(0)
  • 2021-01-06 19:41

    Content after the # is only used on the client side, per HTTP specification. If you require that information on the server, you can either use a different separator, or you can submit it via ajax after the page has loaded by reading it on the client with javascript.

    0 讨论(0)
  • 2021-01-06 19:44

    URI part after # is called a fragment:

    URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

    Scheme and hier-part identify the location of a document, and fragment helps the browser to identify a location inside this document.

    Fragment is stripped from URI by client software before it is sent as a part of request.

    From RFC3986:

    the fragment identifier is not used in the scheme-specific
    processing of a URI; instead, the fragment identifier is separated
    from the rest of the URI prior to a dereference, and thus the
    identifying information within the fragment itself is dereferenced
    solely by the user agent, regardless of the URI scheme. Although
    this separate handling is often perceived to be a loss of
    information, particularly for accurate redirection of references as
    resources move over time, it also serves to prevent information
    providers from denying reference authors the right to refer to
    information within a resource selectively.

    0 讨论(0)
  • 2021-01-06 19:45

    you can do this with javascript

     <script>
     if(window.location.hash) {
        console.log(window.location.hash); 
        window.location.hash = window.location.hash;
     } 
    </script>
    
    0 讨论(0)
提交回复
热议问题