根据用户输入重定向到子域的表单
我需要编写一个表单脚本来根据表单中输入的内容重定向用户。我知道这可以通过 JavaScript 来完成,我设法将一些东西放在一起,但它并没有完全达到我想要的效果,即
用户输入文本,例如 mysubdomain,然后点击提交。
然后我希望将它们转发到 mysubdomain.mydomain.com。 我设法做了相反的事情,因此它定向到 mydomain.com/mysubdomain。
I need to put together a form script to redirect the user based on what is entered into the form. I understand this can be done from JavaScript, I managed to put something together but it didn't do quite what I wanted it to do which is
User enters text, for example mysubdomain, then hits submit.
I would then like them to be forwarded to mysubdomain.mydomain.com.
I managed to do the opposite so it directed to mydomain.com/mysubdomain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的意思是
使用与您所在的相同的域(MDN 上有关位置对象的详细信息 ): 假设表格位于 xxxx.mydomain.com
Do you mean
using same domain as you are on (details about the location object here at MDN): and assuming the form is on xxxx.mydomain.com
我认为您可以有一个功能,可以通过用户+您的域重新加载输入的子域,例如
window.location.assign(subdomain + ".yourdomain.com")
看一下 位置对象。
I think you could have a function that reloads the entered subdomain by the user + your domain so like
window.location.assign(subdomain + ".yourdomain.com")
Take a look at the Location object as well.