脚本
function getParam(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return "";
else
return unescape(results[1]);
}
HTML
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/PersonPage/ConfighMessages.aspx?idCompany=javascript:getParam('idCompany');">bbb</asp:HyperLink>
我想如果在网址中idCompany=123
将此HyperLink重定向到PersonPage/ConfighMessages.aspx?idCompany=123
但此代码重定向到:/PersonPage/ConfighMessages.aspx?idCompany=getParam('idCompany');
答案 0 :(得分:0)
$(<%= "#"+HyperLink1.ClientID %>).attr("href","/PersonPage/ConfighMessages.aspx?idCompany="+ getParam('idCompany'));
或
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%= "~/PersonPage/ConfighMessages.aspx?idCompany=" + Request.QueryString["idCompany"]%>'>bbb</asp:HyperLink>
答案 1 :(得分:0)
javascript:getParam('idCompany')
无效。
尝试:
$("#HyperLink1").click(function(){
window.location.href = "~/PersonPage/ConfighMessages.aspx?idCompany="+idCompany;
});