如何用onclick实现超链接在新页面打开
格子1
使用 location.href 属性可以实现直接跳转到新页面。
<div class='grid-item' onclick='location.href='https://www.baidu.com''><span>格子1</span></div>
格子1
使用 window.open 方法并指定 _blank 参数可以实现超链接在新页面打开。
<div class='grid-item' onclick='window.open('https://www.baidu.com', '_blank')'><span>格子1</span></div>
原文地址: https://www.cveoy.top/t/topic/jYHL 著作权归作者所有。请勿转载和采集!