C# 使用Jquery添加和删除查询

C# 使用Jquery添加和删除查询,c#,jquery,asp.net,C#,Jquery,Asp.net,单击btnzoomprevious&btnzoomnext后,我想在我的url中追加一个名为?zoom=1的查询 <div id=zoomview class="view" style="left:100px;<%=isZoom?"":"display:none;" %>"> <div class="side"> <a id="btncloseview" class="btnview" style=

单击btnzoomprevious&btnzoomnext后,我想在我的url中追加一个名为?zoom=1的查询

<div id=zoomview class="view" style="left:100px;<%=isZoom?"":"display:none;" %>">
            <div class="side">
                <a id="btncloseview" class="btnview" style="left:-100px; top:60px;">close</a>
                <a id="btnzoomprevious" class="btnzoomprevious" href="<%=ResolveClientUrl("~/" + gender + "/" + category + "/" + character + "/")%><%=prevproductName%><%=Request.Url.Query%>?zoom=1" style="margin:420px 0 0 -100px; display:<%=statusprev%>"></a>
                <a id="btnzoomnext" class="btnzoomnext" href="<%=ResolveClientUrl("~/" + gender + "/" + category + "/" + character + "/")%><%=nextproductName%><%=Request.Url.Query%>?zoom=1 " style="margin:420px 0px 0 810px; display:<%=statusnext%>"></a>
            </div>
            <%if(!isZoom) {%>
                <img src="<%=productImagesPath + prevproductImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;"/>
                <img src="<%=productImagesPath + nextproductImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;"/>
            <%}else {%>       
                <img data-src="<%=productImagesPath + productImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;">
            <%} %>
        </div>

.jpg“id=“mainImage”alt=“Main Image”style=“高度:800px;宽度:800px;"/>
.jpg“id=“mainImage”alt=“Main Image”style=“高度:800px;宽度:800px;”/>
.jpg“id=“mainImage”alt=“Main Image”style=“高度:800px;宽度:800px;">

我无法在asp中使用该方法,因为zoom=1再次追加。单击btncloseview后,我需要删除房间。

您想做什么?您只是想将查询追加到窗口中的url吗?可能是这样的:

<div id=zoomview class="view" style="left:100px;<%=isZoom?"":"display:none;" %>">
            <div class="side">
                <a id="btncloseview" class="btnview" style="left:-100px; top:60px;">close</a>
                <a id="btnzoomprevious" class="btnzoomprevious" href="<%=ResolveClientUrl("~/" + gender + "/" + category + "/" + character + "/")%><%=prevproductName%><%=Request.Url.Query%>?zoom=1" style="margin:420px 0 0 -100px; display:<%=statusprev%>"></a>
                <a id="btnzoomnext" class="btnzoomnext" href="<%=ResolveClientUrl("~/" + gender + "/" + category + "/" + character + "/")%><%=nextproductName%><%=Request.Url.Query%>?zoom=1 " style="margin:420px 0px 0 810px; display:<%=statusnext%>"></a>
            </div>
            <%if(!isZoom) {%>
                <img src="<%=productImagesPath + prevproductImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;"/>
                <img src="<%=productImagesPath + nextproductImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;"/>
            <%}else {%>       
                <img data-src="<%=productImagesPath + productImageZoom %>.jpg" id="mainImage" alt="Main Image" style="height:800px; width:800px;">
            <%} %>
        </div>
<script type='text/javascript'>
  $("#btnzoomprevious").on("click", function() {
     if (window.location.href.indexOf('?zoom=1') == -1) {
        window.location.href = window.location.href + '?zoom=1';
     }
  });

  $("#btnzoomnext").on("click", function() {
    if (window.location.href.indexOf('?zoom=1') == -1) {
        window.location.href = window.location.href + '?zoom=1';
    }
  });

  $("#btncloseview").on("click", function() {
    if (window.location.href.indexOf('?zoom=1') != -1) {
        window.location.href = window.location.href.substring(0, window.location.href.indexOf('?zoom=1'));
    }
  });
</script>
<script type='text/javascript'>

    var urlPath = '';

    $("#btnzoomprevious").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') == -1) {
            urlPath = window.location.href + '?zoom=1';
            window.history.pushState("","", urlPath);
        }
    });

    $("#btnzoomnext").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') == -1) {
           urlPath = window.location.href + '?zoom=1';
           window.history.pushState("","", urlPath);
        }
    });

    $("#btncloseview").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') != -1) {
           urlPath = window.location.href.substring(0, window.location.href.indexOf('?zoom=1'));
           window.history.pushState("","", urlPath);
        }
    });

</script>
所以,你可以这样做:

<script type='text/javascript'>
  $("#btnzoomprevious").on("click", function() {
     if (window.location.href.indexOf('?zoom=1') == -1) {
        window.location.href = window.location.href + '?zoom=1';
     }
  });

  $("#btnzoomnext").on("click", function() {
    if (window.location.href.indexOf('?zoom=1') == -1) {
        window.location.href = window.location.href + '?zoom=1';
    }
  });

  $("#btncloseview").on("click", function() {
    if (window.location.href.indexOf('?zoom=1') != -1) {
        window.location.href = window.location.href.substring(0, window.location.href.indexOf('?zoom=1'));
    }
  });
</script>
<script type='text/javascript'>

    var urlPath = '';

    $("#btnzoomprevious").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') == -1) {
            urlPath = window.location.href + '?zoom=1';
            window.history.pushState("","", urlPath);
        }
    });

    $("#btnzoomnext").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') == -1) {
           urlPath = window.location.href + '?zoom=1';
           window.history.pushState("","", urlPath);
        }
    });

    $("#btncloseview").on("click", function() {
        if (window.location.href.indexOf('?zoom=1') != -1) {
           urlPath = window.location.href.substring(0, window.location.href.indexOf('?zoom=1'));
           window.history.pushState("","", urlPath);
        }
    });

</script>

var urlPath='';
$(“#btnzoomprevious”)。在(“单击”,函数(){
if(window.location.href.indexOf('?zoom=1')=-1){
urlPath=window.location.href+'?缩放=1';
window.history.pushState(“,”,urlPath);
}
});
$(“#btnzoomnext”)。在(“单击”,函数(){
if(window.location.href.indexOf('?zoom=1')=-1){
urlPath=window.location.href+'?缩放=1';
window.history.pushState(“,”,urlPath);
}
});
$(“#btncloseview”)。在(“单击”,函数()上{
if(window.location.href.indexOf('?zoom=1')!=-1){
urlPath=window.location.href.substring(0,window.location.href.indexOf(“?zoom=1”);
window.history.pushState(“,”,urlPath);
}
});
您可以在此处找到David Murdoch关于更新URL的原始帖子,无需重新加载页面即可获得更多信息:

祝你好运