锚链接内的按钮在 Firefox 中有效,但在 Internet Explorer 中无效?

编程入门 行业动态 更新时间:2024-10-21 14:31:14
本文介绍了锚链接内的按钮在 Firefox 中有效,但在 Internet Explorer 中无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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="indynile99.blogspot"> <button style="width:120;height:25">Blog</button> </a> <p>&nbsp;</p> </td>

推荐答案

您不能在 元素中包含 .作为 W3 的内容模型 元素状态的描述:

You can't have a <button> inside an <a> element. As W3's content model description for the <a> element states:

不得有交互式内容后代."

"there must be no interactive content descendant."

(a 被认为是 互动内容)

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

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" onClick="javascript:location.href = 'stackoverflow';" />

但是请考虑不要这样做;常规链接可以正常工作是有原因的:

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

  • 用户可以立即识别链接并理解他们导航到其他页面
  • 搜索引擎可以将它们识别为链接并关注它们
  • 屏幕阅读器可以将它们识别为链接并适当地向用户提供建议

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

You also add a completely unnecessary requirement to have JavaScript enabled just to perform a 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 color, border and other techniques, so that they look like buttons, but under the covers, they should be ordinary links.

更多推荐

锚链接内的按钮在 Firefox 中有效,但在 Internet Explorer 中无效?

本文发布于:2023-11-01 20:14:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550302.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:锚链   但在   按钮   Firefox   Internet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!