我有一个用散列(#)获取url地址页面: localhost:15164/L3/mobile/#Android/Alcatel
我想用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>页面加载(从jquery获取地址):
protected void Page_Load(object sender, EventArgs e)
{
urlLable.DataBind();
string urlStr = urlLable.Text;
Response.Write(urlStr);
}发布于 2016-06-01 14:27:33
哈希可以在这里找到:
location.hashhttps://stackoverflow.com/questions/37560859
复制相似问题