Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML open link click anywhere

I'm a mobile programmer who never developed any webpage

I've created a blank HTML page and I want to open new link when the user click or tap anywhere.

Is it possible?

like image 659
MAMN84 Avatar asked Sep 16 '25 06:09

MAMN84


1 Answers

that's an interesting question with many solutions. I'll post two.

Solution 1 - use a full width anchor tag

<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>

Solution 2 - use javascript, and add a click event on the body

<html>
    <body onclick='window.location.href="http://google.com"'>
    </body>
</html>
like image 66
kennypu Avatar answered Sep 17 '25 20:09

kennypu