如何制作一个脚本,通过添加表单中提供的输入来生成url



我想做一个javascript,将重定向到将通过添加表单和主url提供的输入生成的url。

例如:如果用户将'Hello'放入文本框中然后应该重定向到'https://example.domain/Hello'如果他输入Bye那么它应该重定向到'https://example.domain/Bye'

您可以简单地获取textput的值并将其附加到baseurl

const inputBox = document.getElementById("input");
let newURL = 'https://example.domain/' + inputBox.value;

请提供一些代码时张贴问题的SO。遵循指南https://stackoverflow.com/help/how-to-ask

最新更新