我有用于从用户的电子邮件输入中获取电子邮件域的代码。
<input type="text" id="email" class="required form-control" maxlength="120" />
<script>
const email = "person@example.com";
const [, domain] = email.split("@");
document.getElementById("button").setAttribute("href", `http://${domain}`)
</script>
成功页面按钮:
<a id="button">Link</a>
如何将值从注册页面转移到成功页面?
最佳答案
如果页面位于同一域中:
- 使用 localStorage 存储信息,在新的点击/重定向完成时读取信息
否则:
- 判断是否可以通过在 url 中设置查询来设置字段值,如:http://www.page-form.com/form?email=person@example.com&cc=person2@example.com
关于javascript - 如何将值带到新页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56234893/