Frage

I've inherited a forum which has an unsupported and abandoned mod that makes the entire td element that enclosing any link to sub-forums or threads clickable. It's meant as a usability measure, making it easy to just click on the big table cell that contains the sub-forum or thread you'd like to view.

The problem is that the javascript is not 'middle-click' friendly: using any of the normal keyboard or mouse methods to open links in a new window or tab opens the link in BOTH a new tab AND reloads the current window with the click-on link.

This runs counter to expected behaviour and I'd like to find a solution that allows both the usability feature it introduces AND for standard link-clicking behaviour.

Here's the code that is appended to the containing element:

<td class="info" onclick="window.location.href='http://www.bestcafes.com.au/forum/index.php?board=13.0'" name="b13">

Any suggestions would be most welcome!

War es hilfreich?

Lösung

Moving the link to a standard anchor element should do the job:

<td class="info">
    <a href="http://www.bestcafes.com.au/forum/index.php?board=13.0" name="b13">
        …
    </a>
</td>

As suggested in the comments, you also might style them appropriately:

td.info > a { /* only table-cell-links, might need a better selector */
    display: block;
    width:100%; height:100%; /* as long as this doesn't collide with any padding */
    color: inherit; text-decoration: inherit; /* depending on your link style */
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top