<tfoot id='xtfFc'></tfoot>

      <bdo id='xtfFc'></bdo><ul id='xtfFc'></ul>

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

      <small id='xtfFc'></small><noframes id='xtfFc'>

      <legend id='xtfFc'><style id='xtfFc'><dir id='xtfFc'><q id='xtfFc'></q></dir></style></legend>
    2. 是否可以一次更改网站上的所有锚标签属性?

      Is it possible to change all anchor tags properties on a website at once?(是否可以一次更改网站上的所有锚标签属性?)
    3. <small id='mVZkD'></small><noframes id='mVZkD'>

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

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

            <bdo id='mVZkD'></bdo><ul id='mVZkD'></ul>
                  <tbody id='mVZkD'></tbody>
                本文介绍了是否可以一次更改网站上的所有锚标签属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我最近了解到 target="_blank" 是易受攻击的,我们必须使用 rel="noopener".我正在开发一个网站项目,其中所有锚标记都使用目标属性.

                I have recently learned that target="_blank" is vulnerable and we have to use rel="noopener". I am working on a website project where all anchor tags are using the target attribute.

                只需使用以下命令即可一次更改这些锚文本的颜色:

                It is possible to change the colors of these anchor texts at once just by using:

                a {color: blue;}
                

                在网站的头部.

                但如果我尝试这样做

                a {
                rel="noopener"
                target ="_blank"
                }
                

                上面的代码没有任何作用.因为 CSS 没有涵盖 rel 和 target.

                The above code does not have any effect. Because rel and target are not covered in CSS.

                那么,如何才能为整个网站设置这些属性?

                So how could someone set these attributes for the entire site?

                另外,我尝试在 w3schools 上进行搜索,但他们在 CSS 中没有任何答案.

                Also, I tried searching on w3schools but they don't have any answer to it in CSS.

                推荐答案

                使用 Vanilla JS 查找元素.循环然后更改属性.

                Find elements using Vanilla JS. Loop then change attributes.

                document.querySelectorAll('a[target="_blank"]').forEach(function(el){
                    el.setAttribute('rel', 'noopener');
                });
                

                然后应用 CSS

                a[target ="_blank"][rel="noopener"] {
                    color: blue;
                }
                

                这篇关于是否可以一次更改网站上的所有锚标签属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)

                  <bdo id='VEd79'></bdo><ul id='VEd79'></ul>
                      • <legend id='VEd79'><style id='VEd79'><dir id='VEd79'><q id='VEd79'></q></dir></style></legend>

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

                          <small id='VEd79'></small><noframes id='VEd79'>