Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clickable div that redirect me to another HTML page

I would like to click on the DIV (article-column1) ("which is a rectangle")

and it should redirect me to another HTML document:

https://s3-us-west-1.amazonaws.com/example/the-example.html

Blockquote

<style>
    #content1 {
      width: 70%;
      overflow: auto;
      margin: 4% 0% 0% 23%;
      padding-left: 6%;
     }

    #content1 div {
      float: left;
      width:27%;
      height:20%;
      background-color: #efefef;
      margin: 1% 3% 2% 0%;
      padding: 2% 2% 1% 2%;
      text-align: center;
    }

   #content1 p {
      color:#f91d04;
    }

   .article-column1 {
      -moz-box-shadow: -5px 5px 29px #777777;
      -webkit-box-shadow: -5px 5px 29px #777777;
      box-shadow: -5px 5px 29px #777777;
      border-radius: 3px;
      -moz-border-radius: 3px;
      -webkit-border-radius: 3px;
      }

   .article-column2 {
       -moz-box-shadow: -5px 5px 29px #777777;
       -webkit-box-shadow: -5px 5px 29px #777777;
       box-shadow: -5px 5px 29px #777777;
       border-radius: 3px;
       -moz-border-radius: 3px;
       -webkit-border-radius: 3px;
      }

   .article-column3{
      -moz-box-shadow: -5px 5px 29px #777777;
      -webkit-box-shadow: -5px 5px 29px #777777;
      box-shadow: -5px 5px 29px #777777;
      border-radius: 3px;
      -moz-border-radius: 3px;
      -webkit-border-radius: 3px;
      }

    .article-column4 {
     -moz-box-shadow: -5px 5px 29px #777777;
     -webkit-box-shadow: -5px 5px 29px #777777;
     box-shadow: -5px 5px 29px #777777;
     border-radius: 3px;
     -moz-border-radius: 3px;
     -webkit-border-radius: 3px;
     }
</style>
<body>
<div id="content1">
   <div class="article-column1">
         <img src ="https://s3-us-west-1.amazonaws.com/plus32med.png">
         <p>New Workout</a></p> 
   </div>

   <div class="article-column2"> 
        <img src = "https://s3-us-west-1.amazonaws.com/clock61.png">
        <p>History</p>
   </div>

   <div class="article-column3">
        <img src = "https://s3-us-west-1.amazonaws.com/money57.png">       
        <p>Graph</p> 
   </div>

   <div class="article-column4">
        <img src = "https://s3-us-west-1.amazonaws.com/play11.png">
        <p>video</p> 
   </div>
</div>
</body>

Blockquote

like image 692
AziCode Avatar asked Dec 31 '14 02:12

AziCode


4 Answers

in HTML5 you can wrap your <div> inside an anchor element.
SEO-wise is always better to use an Anchor tag instead of JavaScript onclick handlers:

<a href="page.html">
    <div>Yey I'm clickable</div>
</a>

PS: make sure to not have other anchor or action button elements within the wrapping <a>.

like image 71
Roko C. Buljan Avatar answered Nov 18 '22 06:11

Roko C. Buljan


<div onclick="window.location.href = 'http://example.com';">Click this div to get redirected.</div>
like image 29
Drazzah Avatar answered Nov 18 '22 04:11

Drazzah


Manipulate window.location.href on element click:

document.querySelector('.article-column1').addEventListener('click', function(e) {
    window.location.href = 'http://example.com';
}, false);
like image 2
Leo Avatar answered Nov 18 '22 04:11

Leo


use this

<a class="article-column1" href="****link****">
    <img src ="https://s3-us-west-1.amazonaws.com/plus32med.png">
</a>

and CSS

.article-column1 {
  -moz-box-shadow: -5px 5px 29px #777777;
  -webkit-box-shadow: -5px 5px 29px #777777;
  box-shadow: -5px 5px 29px #777777;
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  display : block;
  }
like image 1
MegaMind Avatar answered Nov 18 '22 05:11

MegaMind