Nix*_*ova 5 url google-chrome character-encoding
Firefox 等浏览器会显示包含空格(包括 nbsp)的 URL,其中包含实际空格 ( );Chrome 始终在地址栏中将空格显示为
%20
(以及 nbsp 的显示为)。%C2%A0
(即,Firefoxhttp://example.com/A B
在地址栏中显示,而 Chrome 显示http://example.com/A%20B
。)有没有办法让 Chrome 显示空格而不是
%20
?
如果您可以使用下划线而不是空格(就像我的例子,我只需要提高 URL 的可读性),您可以使用:
window.history.pushState("string", "Title", window.location.href.replace(new URL(window.location.href, location).origin+'/', '').replaceAll('%20','_'))
Run Code Online (Sandbox Code Playgroud)
(最后replaceAll
一个可以是空格而不是下划线,但 Chrome 无论如何都会用 %20 替换它)
也许使用 Chrome 扩展可以做得更好。
归档时间: |
|
查看次数: |
1352 次 |
最近记录: |