admin管理员组

文章数量:1404563

i have a following url

#gbar

where #gbar is a Anchor. if this anchor is available i have to do to hide some div and show some div . How will i check if the url has this anchor ,because it is not a query string we cna't use request.querystring.get() .Any ideas ??

i have a following url

http://example.aspx#gbar

where #gbar is a Anchor. if this anchor is available i have to do to hide some div and show some div . How will i check if the url has this anchor ,because it is not a query string we cna't use request.querystring.get() .Any ideas ??

Share Improve this question asked Oct 27, 2010 at 4:57 user370312user370312 1273 silver badges9 bronze badges 1
  • Are you looking for code or javascript? – Drew LeSueur Commented Oct 27, 2010 at 4:58
Add a ment  | 

3 Answers 3

Reset to default 4

Javascript location hash property sets or returns the value from the hash sign "#" in the current URL of the browser window. Javascript location hash actually returns the bookmark name form the current URL. Bookmark hash "#" sign provides the functionality to target the named anchor HTML tag within the same other web pages. When you click on any link text that targets the bookmarked location of any webpage it adds the "#" symbol and bookmark name to the end of the URL. You can place the location.hash or window.location.hash code inside the target page to retrieve the current bookmark name from the URL. You can call the function at page load or click event of the button.

    <html>
<head>
    <title>Javascript Window Location Hash</title>

    <script type="text/javascript" language="javascript">
    function getLocationHash()
    {
        alert(window.location.hash);
    }

    function setLocationHash()
    {
        window.location.hash = "#top";
    }

    </script> 

</head>
<body>


    <p>
        Click here to <a name="top" href="#bottom" style="color: blue"><b>go to Bottom >></b></a> <br />
        Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text <br />
    </p>
    <p>
        Click here to <a name="bottom" href="#top" style="color: blue"><b>go to Top</b></a>
    </p>  

    <input type="button" onclick="getLocationHash();" value="get Location Hash" />
    <input type="button" onclick="setLocationHash();" value="set Location #Top" /> 

</body>
</html>

In JavaScript

location.hash

Edit: Changed from "document.location" on advice below

location.hash

本文标签: javascriptGet Value from UrlStack Overflow