Using “&” and “+” in Querystring

前端 未结 4 406
礼貌的吻别
礼貌的吻别 2021-01-27 09:18

In call the following URL in Javascript.

var par = \"Participant.aspx?ID=\" + Id + \"&NAME=\" + Name+ \"&FIRSTNAME=\" + Firstname;

Some

4条回答
  •  天涯浪人
    2021-01-27 10:05

    You can use encodeURIComponent for the query string value and then set it as query string

        var url = encodeURIComponent($("#<%=hdnPageQuery.ClientID%>").val());
        var title = encodeURIComponent(document.title);
        var redirectUrl = $("#<%=hdnPageTarget.ClientID%>").val();
        var outputUrl = redirectUrl + '?url=' + url + '&title=' + title;
        $('#ancSendToFriendLink').attr('href', outputUrl);
    

提交回复
热议问题