锚链接中的按钮在Firefox中可用,但在Internet Explorer中不可用? [英] Button inside of anchor link works in Firefox but not in Internet Explorer?

查看:84
本文介绍了锚链接中的按钮在Firefox中可用,但在Internet Explorer中不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中的其他内容似乎都与所有浏览器兼容,除了我的链接。它们出现在页面上,但它们不工作。我的链接代码如下 -

 < td bgcolor =#ffffffheight =370valign = topwidth =165> 
< p>
< a href =sc3.html>
< button style =width:120; height:25> Super Chem#3< / button>
< / a>
< a href =91hollywood.html>
< button style =width:120; height:25> 91 Hollywood< / button>
< / a>
< a href =sbubba.html>
< button style =width:120; height:25>超级泡泡< / button>
< / a>
< a href =afgoohash.html>
< button style =width:120; height:25> Afgoo Hash< / button>
< / a>
< a href =superjack.html>
< button style =width:120; height:25>超级杰克< / button>
< / a>
< a href =sog.html>
< button style =width:120; height:25> Sugar OG< / button>
< / a>
< a href =91pk91.html>
< button style =width:120; height:25> 91 x PK< / button>
< / a>
< a href =jedi1.html>
< button style =width:120; height:25> Jedi< / button>
< / a>
< / p>
< p>& nbsp;< / p>
< a href =http://indynile99.blogspot.com>
< button style =width:120; height:25>博客< / button>
< / a>
< p>& nbsp;< / p>
< / td>


解决方案

您不能有元素内的< button>



交互式元素按钮不能作为a元素的后代出现。资料来源: http://www.w3.org/ TR / html-markup / button.button.html#button.button



为了获得你想要的效果,你可以把< a> 标签放在每个按钮上,并将一个简单的事件处理程序导航到浏览器到所需的位置,例如

 < input type =buttonvalue =stackoverflow.comonClick =javascript:location.href = http://stackoverflow.com'; /> 

但请注意




  • 用户可以即时识别链接,并了解他们导航到其他页面

  • 屏幕阅读器可以将其标识为链接并适当地建议其用户

  • ul>

    您还添加了一个完全不必要的要求,即仅启用JavaScript才能执行基本导航;这是网络的一个基本方面,我认为这种依赖是不可接受的。



    您可以使用背景图片或背景颜色,边框和其他技术,以便他们看起来像按钮,但在封面下,他们应该是普通的链接。


    Everything else in my site seems to be compatible with all browsers except for my links. They appear on the page, but they do not work. My code for the links are as follows-

    <td bgcolor="#ffffff" height="370" valign="top" width="165">
        <p>
            <a href="sc3.html">
                <button style="width:120;height:25">Super Chem #3</button>
            </a> 
            <a href="91hollywood.html">
                <button style="width:120;height:25">91 Hollywood</button>
            </a> 
            <a href="sbubba.html">
                <button style="width:120;height:25">Super Bubba</button>
            </a> 
            <a href="afgoohash.html">
                <button style="width:120;height:25">Afgoo Hash</button>
            </a> 
            <a href="superjack.html">
                <button style="width:120;height:25">Super Jack</button>
            </a> 
            <a href="sog.html">
                <button style="width:120;height:25">Sugar OG</button>
            </a> 
            <a href="91pk91.html">
                <button style="width:120;height:25">91 x PK</button>
            </a> 
            <a href="jedi1.html">
                <button style="width:120;height:25">Jedi</button>
            </a>
        </p>
        <p>&nbsp;</p>
        <a href="http://indynile99.blogspot.com">
            <button style="width:120;height:25">Blog</button>
        </a>
        <p>&nbsp;</p>
    </td>
    

    解决方案

    You can't have a <button> inside an <a> element.

    "The interactive element button must not appear as a descendant of the a element." Source: http://www.w3.org/TR/html-markup/button.button.html#button.button

    To get the effect you're looking for, you can ditch the <a> tags and add a simple event handler to each button which navigates the browser to the desired location, e.g.

    <input type="button" value="stackoverflow.com" onClick="javascript:location.href = 'http://stackoverflow.com';" />
    

    Please consider not doing this, however; there's a reason regular links work as they do:

    • Users can instantly recognise links, and understand that they navigate to other pages
    • Search engines can identify them as links and follow them
    • Screen readers can identify them as links and advise their users appropriately

    You also add a completely unnecessary requirement to have JavaScript enabled just to perform basic navigation; this is such a fundamental aspect of the web that I would consider such a dependency as unacceptable.

    You can style your links, if desired, using a background image or background colour, border and other techniques, so that they look like buttons, but under the covers, they should be ordinary links.

    这篇关于锚链接中的按钮在Firefox中可用,但在Internet Explorer中不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆