• <small id='JMemk'></small><noframes id='JMemk'>

      <bdo id='JMemk'></bdo><ul id='JMemk'></ul>
      <i id='JMemk'><tr id='JMemk'><dt id='JMemk'><q id='JMemk'><span id='JMemk'><b id='JMemk'><form id='JMemk'><ins id='JMemk'></ins><ul id='JMemk'></ul><sub id='JMemk'></sub></form><legend id='JMemk'></legend><bdo id='JMemk'><pre id='JMemk'><center id='JMemk'></center></pre></bdo></b><th id='JMemk'></th></span></q></dt></tr></i><div id='JMemk'><tfoot id='JMemk'></tfoot><dl id='JMemk'><fieldset id='JMemk'></fieldset></dl></div>

      <legend id='JMemk'><style id='JMemk'><dir id='JMemk'><q id='JMemk'></q></dir></style></legend>

      1. <tfoot id='JMemk'></tfoot>

        在&lt;option&gt;中使用href链接标签

        using href links inside lt;optiongt; tag(在lt;optiongt;中使用href链接标签)

          <tfoot id='7wvr6'></tfoot>
            <bdo id='7wvr6'></bdo><ul id='7wvr6'></ul>
              <tbody id='7wvr6'></tbody>
            <legend id='7wvr6'><style id='7wvr6'><dir id='7wvr6'><q id='7wvr6'></q></dir></style></legend>

              <small id='7wvr6'></small><noframes id='7wvr6'>

              <i id='7wvr6'><tr id='7wvr6'><dt id='7wvr6'><q id='7wvr6'><span id='7wvr6'><b id='7wvr6'><form id='7wvr6'><ins id='7wvr6'></ins><ul id='7wvr6'></ul><sub id='7wvr6'></sub></form><legend id='7wvr6'></legend><bdo id='7wvr6'><pre id='7wvr6'><center id='7wvr6'></center></pre></bdo></b><th id='7wvr6'></th></span></q></dt></tr></i><div id='7wvr6'><tfoot id='7wvr6'></tfoot><dl id='7wvr6'><fieldset id='7wvr6'></fieldset></dl></div>
                  本文介绍了在&lt;option&gt;中使用href链接标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下 HTML 代码:

                  I have the following HTML code:

                  <select name="forma">
                      <option value="Home">Home</option>
                      <option value="Contact">Contact</option>
                      <option value="Sitemap">Sitemap</option>
                  </select>
                  

                  如何将 HomeContactSitemap 值设为链接?我使用了以下代码,但正如我所料,它不起作用:

                  How can I make Home, Contact and Sitemap values as links? I used the following code and as I expected it didn't work:

                  <select name="forma">
                      <option value="Home"><a href="home.php">Home</a></option>
                      <option value="Contact"><a href="contact.php">Contact</a></option>
                      <option value="Sitemap"><a href="sitemap.php">Sitemap</a></option>
                  </select>
                  

                  推荐答案

                  <select name="forma" onchange="location = this.value;">
                   <option value="Home.php">Home</option>
                   <option value="Contact.php">Contact</option>
                   <option value="Sitemap.php">Sitemap</option>
                  </select>
                  

                  更新(2015 年 11 月):在这个时代,如果您想拥有下拉菜单,可以说有很多 更好的实现方法. 这个答案是对直接问题的直接回答,但我不提倡这种方法用于面向公众的网站.

                  UPDATE (Nov 2015): In this day and age if you want to have a drop menu there are plenty of arguably better ways to implement one. This answer is a direct answer to a direct question, but I don't advocate this method for public facing web sites.

                  更新(2020 年 5 月):有人在评论中问我为什么不提倡这种解决方案.我想这是一个语义问题.我宁愿我的用户使用 <a> 导航并保留 <select> 进行表单选择,因为 HTML 元素具有语义会议并且它们有目的,anchors 带你去地方,<select> 用于从列表中挑选东西.

                  UPDATE (May 2020): Someone asked in the comments why I wouldn't advocate this solution. I guess it's a question of semantics. I'd rather my users navigate using <a> and kept <select> for making form selections because HTML elements have semantic meeting and they have a purpose, anchors take you places, <select> are for picking things from lists.

                  考虑一下,如果您使用非传统浏览器(非图形浏览器或屏幕阅读器,或者以编程方式访问该页面,或禁用 JavaScript)查看页面,那么含义"或意图"是什么?这个 <select> 你是用来导航的吗?它说的是请选择一个页面名称",而不是其他很多,当然与导航无关.对此的简单回应是 我知道我的用户将使用 IE 或其他任何东西耸耸肩 但这有点忽略了语义重要性.

                  Consider, if you are viewing a page with a non-traditional browser (a non graphical browser or screen reader or the page is accessed programmatically, or JavaScript is disabled) what then is the "meaning" or the "intent" of this <select> you have used for navigation? It is saying "please pick a page name" and not a lot else, certainly nothing about navigating. The easy response to this is well i know that my users will be using IE or whatever so shrug but this kinda misses the point of semantic importance.

                  而一个时髦的下拉 UI 元素由合适的布局元素(和一些 js)组成,包含一些常规锚点,即使布局元素丢失,它仍然保留它的意图,这些是一堆链接,选择一个,我们将导航到那里".

                  Whereas a funky drop-down UI element made of suitable layout elements (and some js) containing some regular anchors still retains it intent even if the layout element is lost, "these are a bunch of links, select one and we will navigate there".

                  这是一篇关于 <select> 的误用和滥用的文章.

                  Here is an article on the misuse and abuse of <select>.

                  这篇关于在&lt;option&gt;中使用href链接标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                  SmtpJs API not working! is there any way to send emails using SMTP server with JavaScript or JQuery(SmtpJs API 不工作!有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮件)
                  Can I send email using javascript(我可以使用 javascript 发送电子邮件吗)
                  Select All the objects on canvas using Fabric.js(使用 Fabric.js 选择画布上的所有对象)
                  Crop the image using JavaScript(使用 JavaScript 裁剪图像)

                      <bdo id='5dSxj'></bdo><ul id='5dSxj'></ul>
                          <tbody id='5dSxj'></tbody>

                        <small id='5dSxj'></small><noframes id='5dSxj'>

                        <i id='5dSxj'><tr id='5dSxj'><dt id='5dSxj'><q id='5dSxj'><span id='5dSxj'><b id='5dSxj'><form id='5dSxj'><ins id='5dSxj'></ins><ul id='5dSxj'></ul><sub id='5dSxj'></sub></form><legend id='5dSxj'></legend><bdo id='5dSxj'><pre id='5dSxj'><center id='5dSxj'></center></pre></bdo></b><th id='5dSxj'></th></span></q></dt></tr></i><div id='5dSxj'><tfoot id='5dSxj'></tfoot><dl id='5dSxj'><fieldset id='5dSxj'></fieldset></dl></div>
                          <tfoot id='5dSxj'></tfoot>
                          <legend id='5dSxj'><style id='5dSxj'><dir id='5dSxj'><q id='5dSxj'></q></dir></style></legend>