为什么单击“确定”后网络表单会重置
我编写了以下脚本来使用 href
弹出一条消息,但是单击弹出窗口的 OK
后,表单将被重置,为什么会发生这种情况
我写的内容如下
<a href="" style="text-decoration: none;" onclick="return confirm('A student need for Accommodated, Modified, or Alternate assessment is determined by the student ARD committee working in collabration with the LPAC and must be documneted in the student IEP ');">
?</a>
在“确定”之前,单击
单击“确定”后
I have written the following script to pop up a message using href
but on clicking OK
of the pop up the form is getting reset why this is happening
What I wrote is as follows
<a href="" style="text-decoration: none;" onclick="return confirm('A student need for Accommodated, Modified, or Alternate assessment is determined by the student ARD committee working in collabration with the LPAC and must be documneted in the student IEP ');">
?</a>
Before OK click
After clicking ok
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
奇怪的是,您使用
confirm()
来弹出信息窗口。 OK 和 Cancel 之间没有区别,所以你可以只使用alert()
,你还需要返回 false,这样它实际上不会跟随链接:您发布的原始版本链接到当前页面(并使用现在为空的表单重新加载页面。)
您还可以使用跨度:
It's odd that you're using
confirm()
for an informational pop-up. There's no difference between OK and Cancel, so you can just usealert()
, you also need to return false so it does not actually follow the link:The original version you posted was linking to the current page (and reloading the page with a now empty form.)
You could also use a span:
这是因为在确认框中单击“确定”将返回 true,这将导致锚点
“继续”其默认行为,在这种情况下(没有定义的 href)将重新加载当前页面。考虑使用不同的标签,例如 <跨度>
编辑:或者如下所述,尝试
在标记内的函数调用之后添加。
that's because clicking OK in a confirm box will return true, which will cause the anchor to
'continue' with it's default behavior, which in this case (without a defined href) will reload the current page. Consider using a different tag, like < span >
edit: or as noted below, try adding
after the function call within the tag.