0

So I'm putting together a website, and for some reason I decided to use a table for the header. The only issue with this, is that I wanted the whole section of the to be selectable on click. To remedy this issue, I used the simple onClick thing in HTML. Here's my code for the table:

<table cols="8" height="60px" width="600" class="tableheader">
            <tr>
                <td onClick="document.location.href='index.html';" class="tdlink">
                <strong>HOME</strong>
                </td>
                <td class="tddot">
                |
                </td>
                <td onClick="document.location.href='aboutus.html';" class="tdlink">
                <strong>ABOUT US</strong>
                </td>
                <td class="tddot">
                |
                </td>
                <td onClick="document.location.href='services.html';"  class="tdlink">
                <strong>SERVICES</strong>
                </td>
                <td class="tddot">
                |
                </td>
                <td onClick="document.location.href='contact.php';"  class="tdlink">
                <strong>CONTACT</strong>
                </td>
                <td class="tddot">
                |
                </td>
                <td onClick="document.location.href='scheduledeposition.php';"  class="tdlink">
                <strong>SCHEDULE<br>DEPOSITION</strong>
                </td>
            </tr>
        </table>

The issue I'm running into is that whenever I right click on these items, they don't open up a link menu, but instead the standard blank-space browser right click menu. Is there any way to solve this?

I'm open to the idea of using jQuery or JavaScript, but in briefly looking I haven't found anything that would remedy this issue that I can even understand.

  • Check out [this question](http://stackoverflow.com/questions/1206203/how-to-distinguish-between-left-and-right-mouse-click-with-jquery). May be helpful? – Blundering Philosopher Mar 21 '14 at 19:40
  • 1
    Why not use real links and style them? I mean, you can set with and height on a link with css, just link you can on a td. Your way is a bit ugly. –  Mar 21 '14 at 19:42
  • @Fibbe Alright, I'll probably try that then. I still have a week or two before the deadline, so as long as it all goes smoothly I'll be able to throw it together. Thanks for your help, friend. – user3108660 Mar 21 '14 at 20:00

1 Answers1

0

You have to use the oncontextmenu event to catch the right click. I think you'll also have to prevent the browsers default right click context menu.

Beemo
  • 17
  • 1
  • 5