有没有任何方法来获取没有查询字符串的URL?

问题描述:

我有一个类似的网址:http://localhost/dms/mduserSecurity/UIL/index.php?menu = true& submenu = true& pcode = 1235

我想获取没有查询字符串的URL: http://localhost/dms/mduserSecurity/UIL/index.php

I want to get the URL without the query string: http://localhost/dms/mduserSecurity/UIL/index.php.

JavaScript中有没有这方法?目前我使用 document.location.href ,但它返回完整的URL。

Is there any method for this in JavaScript? Currently I am using document.location.href, but it returns the complete URL.

试试这个: window.location.href.split('?')[0]