Retrieving Anchor Link In URL for ASP.Net

前端 未结 3 1704
滥情空心
滥情空心 2020-11-27 22:28

I have an url like so:

http://localhost/place/663828/bangkok-paradise-restaurant-toronto#r306040

I am trying to see if theres the existence of the anchor tag

3条回答
  •  醉梦人生
    2020-11-27 22:33

    It's not possible to retrieve the #anchor from the server side in ASP.NET

    This is a client-side flag to tell the browser to move to a specific place within the page.

    You can use some Javascript in the body onLoad event to check for an anchor and send it back to the server using ajax.

    var anchorValue;
    var url = document.location;
    var strippedUrl = url.toString().split("#");
    if(strippedUrl.Length > 1)
    anchorvalue = strippedUrl[1];
    

    ref: http://www.wacdesigns.com/2008/01/16/retrieving-anchor-value-from-url/

提交回复
热议问题