Currently, the way I know of js to obtain the URL carrying parameters is
window.location.search
But suppose there is a link to www.xxxxxx.com?aaa=bbb&ccc=ddd#ok
What is obtained is?aaa=bbb&ccc=ddd#ok
I don’t want the hash value after this #. Can it be removed? Or do I have to use regular expressions to remove it?
The
location object has a
hash
attribute, which stores the string starting with # in the URL, so it is not necessary to use regular replacement. Direct matching replacement can also be used:Reference: http://www.w3school.com.cn/js...
Can you be sure that only one
#
symbol appears in the address string? If possible, get the entire address string, and then use string.IndexOf("#") to get the current character position. Then you can get it at willFor example:
Then
----------------------------------Separating line---------- ------------------
var str = " www.xxxxxx.com?aaa=bbb&ccc=ddd#ok" ;
var url = str.split('#')[0];
It should be possible that there is no direct interception function on your mobile phone
It’s better to judge and split it