Is there any method to get the URL without query string?

后端 未结 14 1308
天涯浪人
天涯浪人 2020-11-28 19:22

I have a URL like http://localhost/dms/mduserSecurity/UIL/index.php?menu=true&submenu=true&pcode=1235.

I want to get the URL without the query s

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 19:45

    Use properties of window.location

    var loc = window.location;
    var withoutQuery = loc.hostname + loc.pathname;
    var includingProtocol = loc.protocol + "//" + loc.hostname + loc.pathname;
    

    You can see more properties at https://developer.mozilla.org/en/DOM/window.location

提交回复
热议问题