简体   繁体   English

评论后如何重定向到同一页面

[英]How to redirect to the same page after comment

     <span class="input-group-btn">
       <button class="btn btn-sm btn-info no-radius" type="submit"  onClick="saveMessage('new')" id="query_btn_margin">
          <i class="ace-icon fa fa-share"></i>
                Add Comment
        </button>
    </span> 

In the conversation field,after Add Comment the page redirects to the next page..how it will be fixed on the same page..?? 在对话字段中,在添加评论之后,页面将重定向到下一页。如何将其固定在同一页面上。

You can write this code after completing your task,write this line.
window.location.href = "newjsp.jsp"

You already call this onclick="saveMessage('new')" function add at the end of the function, 您已经在函数结尾处调用了onclick="saveMessage('new')"函数添加,

window.location = '/'

or you may use this, 或者你可以用这个

window.location = window.location.host;
window.location = window.location.href;

even more you use jquery in your page use, 在页面使用中甚至更多地使用jquery,

$(window).attr("location","http://google.com");

You want to go to next page (next page content is on same page with display:none) after addition of comments... 添加注释后,您想转到下一页(下一页内容在同一页面上,显示:无)。

<input type='button' name='add_comment'  id='add_comment' value='ADD COMMENT'/>

When user click on above button call below js code 当用户单击上面的按钮调用下面的js代码时

$('#add_comment').click(function(){
    $('.currentpage_div_id_to_hide').hide();
   $('.nextpage_div_id_to_show').show();
});

Try this and make sure you can use .js file: 试试看,确保可以使用.js文件:

<script src="../js/jquery.min.js" ></script>

<script>
    $(document).ready(function(){
        $("#submitbutton").click(function(){
            window.location.href = "newjsp.jsp";
        });
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM