i have a page that get url address with hash(#): localhost:15164/L3/mobile/#Android/Alcatel
i want to get url address with jquery and use it on page load event in code behind.
<head runat="server">
<title></title>
<script src="js/jquery1.8.2.js"></script>
<script>
$(document).ready(function () {
var url = window.location.href;
var rest = url.substring(url.lastIndexOf("#") + 1, url.length);
$('#urlLable').text(rest);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="urlLable" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
page load ( to get address from jquery):
protected void Page_Load(object sender, EventArgs e)
{
urlLable.DataBind();
string urlStr = urlLable.Text;
Response.Write(urlStr);
}
哈希在这里可用:
location.hash
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.