简体   繁体   中英

Add a new parameter on URL after the last slash or the last word of the URL

I want to add "/finished" on my URL when click on button withou reloading the page or if it's not possible the "/", only "-finished".

My URL is: www.myname.com/firstparemeter/secondparameter**/finished**

So, the script must add after the last "/" or only add a "-finished" on the last word of the URL.

<script>
$(document).ready(function () {

    $('#btnclick').click(function () {
         window.location.hash = '/finished';
    });

});
</script>

The HTML:

<input type="submit" value="SUBSCRIBE" class="btn-submit" id="btnclick" onclick="IsEmpty();" />

Can you guys help me? I'm begineer

history.pushState({}, "", window.location.hash + "/finished")

也可能是window.location.href

history.pushState({}, '', '/finished')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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