-5

Can I make my <div> tag with onclick() function to have in browser same options like <a> tag ?

I need some options like "open in new window", "copy link location" ...

tomsullivan1989
  • 2,760
  • 14
  • 21
Ivan Vulović
  • 2,147
  • 6
  • 27
  • 43

3 Answers3

3

If you want the div to act like a link, you should be using a link. Set the display to block and you got a block element.

The HTML:

<a class="I_AM_A_BLOCK" href="funky_chicken_dance.html">My Content</a>

The CSS:

.I_AM_A_BLOCK {
    display: block;
}
epascarello
  • 204,599
  • 20
  • 195
  • 236
2

No, but in HTML5 you can wrap links around block-level elements.

<a href="#">
    <div>Hello!</div>
</a>
Lars Beck
  • 3,446
  • 2
  • 22
  • 23
1

No.

You can create a custom context menu, but most options on a link a not replicable in JavaScript (and you have no way of knowing what non-standard options extensions might have added).

You should probably be using a real <a> instead of trying to make a <div> behave like one.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335