i have a page that get url address with hash(#): localhost:15164/L3/mobile/#Android/Alcatel
我有一个页面,使用hash(#)获取url地址:localhost:15164 / L3 / mobile / #Android / Alcatel
i want to get url address with jquery and use it on page load event in code behind.
我想用jquery获取url地址并在代码后面的页面加载事件中使用它。
<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):
页面加载(从jquery获取地址):
protected void Page_Load(object sender, EventArgs e)
{
urlLable.DataBind();
string urlStr = urlLable.Text;
Response.Write(urlStr);
}
1 个解决方案
#1
0
The hash is available here:
哈希在这里可用:
location.hash
#1
0
The hash is available here:
哈希在这里可用:
location.hash