You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ChromeOS中document.write输出带空格URL参数时追加null问题

ChromeOS下URL含空格的参数输出时自动追加null的问题

场景说明

  • 参数传递:通过URL向print.html传递参数,示例地址:.../print.html?name=Peter%20Gram&city=Torshavn
  • 参数获取代码:
<script>
const name = urlParams.get('name')
const city = urlParams.get('city')
</script>
  • 页面输出代码片段:
...
<tr><td>Name:<br><script>document.write(name)</script>
<tr><td>City:<br><script>document.write(city)</script>
...
  • 实际输出结果:

Name:Peter Gramnull

City:Torshavn

问题详情

该问题仅出现在ChromeOS系统的Chromebook设备上,Windows系统的Chrome浏览器无此异常。实际业务场景中传递5个参数,其中3个包含空格(URL中已转义为%20),这3个带空格的参数输出时都会被自动追加null,不带空格的参数则正常显示。

内容的提问来源于stack exchange,提问作者PC-Gram

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 00:53:15