开发者

html clickable layout area. best practice

I am bad in html layout but I have to produce it :) I want to make big button on a page that is implemented as complex html layout with children tags (maybe - 开发者_如何学运维a bad idea). I can handle click event on boundary element with javascript but it requires javascript enabled. I can wrap boundary element with "anchor" tag but is doesn't work in IE

Please, suggest me the best way to implement this.

<a href="...">        
        <table>
            <td>                                
                ...
            </td>
            <td>
                ...
                   <table> ... </table>
            </td>       
        </table>

    </a>


Put an image inside the anchor. The image can be a 1x1 transparent gif. Give it a size that is equal to everything you want to cover. Position the image to cover your table. Then the anchor will contain the whole invisible image as something clickable. This works because it's the same as having a big clickable image and browsers support that.


How about placing all of your content, then using css to absolutely position a giant <a> tag on top of it? The anchor wouldn't need child element's, they would be siblings. The absolute positioning makes the whole area clickable. But make sure the <a> is on top of the z order.


How about some simple JavaScript?

<div style="cursor:pointer;" onClick="javascript:document.location.href='...'><table>...</table></div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜