gpt4 book ai didi

HTML 打开链接点击任意位置

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:03 24 4
gpt4 key购买 nike

我是一名从未开发过任何网页的移动程序员

我创建了一个空白的 HTML 页面,我想在用户点击或点按任意位置时打开新链接。

这可能吗?

最佳答案

这是一个有趣的问题,有很多解决方案。我会发布两个。

解决方案 1 - 使用全宽 anchor 标记

<html>
<head>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
a { display: block; width: 100%; height: 100%; }
</style>
</head>
<body>
<a href='#'></a>
</body>
</html>

解决方案 2 - 使用 javascript,并在正文上添加点击事件

<html>
<body onclick='window.location.href="http://google.com"'>
</body>
</html>

关于HTML 打开链接点击任意位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23190856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com