简体   繁体   English

警报后如何留在同一位置?

[英]How to stay in the same location after an alert?

I have an alert box in JavaScript which is prompted by clicking a link down the page.我在 JavaScript 中有一个警告框,通过单击页面下方的链接来提示。 When the alert box pops up, and the user presses ok, the user is redirected to the top of the page.当警告框弹出,并且用户按确定时,用户被重定向到页面顶部。 How do I make it so the page stays where the user prompted the alert box?如何使页面停留在用户提示警告框的位置? Thanks!谢谢!

Add return false;添加return false; to the end of the link.到链接的末尾。

<a href="#" onclick="alert('Hello, World!'); return false;" > >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM