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
3 Answers
Reset to default 4Javascript 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
版权声明:本文标题:javascript - Get Value from Url - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744829656a2627273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论