在表单中单击提交按钮后,可以通过以下几种方式打开特定的网页:
示例代码:
<form action="https://example.com/target-page.html" method="post">
<!-- 表单字段 -->
<input type="text" name="username" placeholder="用户名">
<input type="password" name="password" placeholder="密码">
<!-- 提交按钮 -->
<input type="submit" value="提交">
</form>
示例代码:
<form>
<!-- 表单字段 -->
<input type="text" name="username" placeholder="用户名">
<input type="password" name="password" placeholder="密码">
<!-- 提交按钮 -->
<input type="submit" value="提交" onclick="openTargetPage()">
</form>
<script>
function openTargetPage() {
// 获取表单数据
var username = document.getElementsByName("username")[0].value;
var password = document.getElementsByName("password")[0].value;
// 构造目标网页的URL,包含表单数据作为参数
var targetUrl = "https://example.com/target-page.html?username=" + username + "&password=" + password;
// 打开目标网页
window.location.href = targetUrl;
}
</script>
以上两种方式都可以实现在表单中单击提交按钮后打开特定的网页。具体选择哪种方式取决于需求和开发环境。
领取专属 10元无门槛券
手把手带您无忧上云