企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
JavaScript修改URL參數: ``` <script> function changeUrlArg(url, arg, val){ var pattern = arg+'=([^&]*)'; var replaceText = arg+'='+val; return url.match(pattern) ? url.replace(eval('/('+ arg+'=)([^&]*)/gi'), replaceText) : (url.match('[\?]') ? url+'&'+replaceText : url+'?'+replaceText); } var url_search = window.location.search; console.log(url_search); console.log(changeUrlArg(url_search, 'id', 4)); </script> ```