设计一个按钮使其返回上一个页面内容:可以使用button标签,并在其中嵌入JavaScript语句,如下所示:

<button type='button' onclick='window.history.back();' style='width:150px;height:50px;border-radius: 30px;background-color: rgb(97, 151, 97);text-align: center;margin-top: 25px;'>返回上一个页面</button>

其中,onclick属性中的window.history.back()表示返回上一个页面。需要注意的是,这个方法只能返回到访问历史中的前一个页面,如果当前页面是通过直接输入URL或者书签进入的,是没有前一个页面的,此时点击按钮不会有任何反应。

如何使用按钮返回上一个页面 - 网站开发技巧

原文地址: https://www.cveoy.top/t/topic/onEX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录