如果URL不变,我应该使用按钮还是链接? [英] Should I use a button or a link if the URL doesn't change?

查看:104
本文介绍了如果URL不变,我应该使用按钮还是链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个仅在启用JavaScript的情况下运行的应用程序(否则,将显示一条适当的消息).应用程序中有两个屏幕:游戏,教程,设置,关于/信用.它们看起来就像单独的页面,但这全都是单页面的应用程序.在屏幕之间导航时,没有URL更改.

I'm building an app which works only with JavaScript enabled (otherwise, an appropriate message is displayed). There are a couple of screens in the app: game, tutorial, settings, about/credits. They look like separate pages, but it's all a single-page app. There are no URL changes when navigating between the screens.

在这种情况下,我应该使用按钮还是锚点?锚也会破坏常见的模式,例如在新标签页/窗口中打开(不更改URL意味着应用程序将在新标签页中从头重新启动).

Should I use a button or an anchor in this case? It feels like an anchor, but there's no page to lead to, meaning that href would have to be #. Also an anchor will break common patterns such as opening in new tab/window (no URL change means the app will restart from scratch in a new tab).

推荐答案

在相同环境中运行的UI元素不应将后备服务提供给另一个URL.从语义的角度来看,<buttons>是可行的方法,但是有时在光学修改需要像简单的<a> -tag那样付出更多努力的情况下实现这些方法,无论如何,<a> -tag都是更好的方法的语义.例如,屏幕阅读器在按钮和锚之间的差别很小,而模仿其他标签的按钮的语义行为的复杂UI在考虑替代标签时会产生更大的权重.

UI-Elements who operate in the same environment should not serve fallbacks to another URL. From the semantic point of view <buttons> are the way to go, but sometimes the implementation of those when optical modifications require more effort as an simple <a>-tag would, an <a>-tag would be the better way, regardless of the semantic. A screen reader for example has only minimal differences between a button and an anchor and complex UIs who mimic the semantic behavior of buttons with other tags have issues with more weight when considering alternative tags.

这篇关于如果URL不变,我应该使用按钮还是链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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