JavaScript-HTML-CSS Days1 Notes

1、这个target参数 是什么含义,_blank 又是什么含义?

<a href="./01-标签的写法.html" target="_blank">跳转到01-标签的写法</a>

在 HTML 中,<a> 标签用于创建超链接,而 target 参数用于指定点击链接时新页面的打开方式。

target 属性的作用

target 属性定义了当用户点击超链接时,链接应该在什么地方打开。常见的 target 值包括:

  1. _self (默认值):在当前窗口或选项卡中打开链接。这是默认行为,如果你不指定 target,浏览器会使用 _self

<a href="example.html" target="_self">在当前窗口打开</a>

  2. _blank:在新窗口或新标签中打开链接。常用于在保持当前页面的同时,打开一个新的页面。

<a href="example.html" target="_blank">在新标签或窗口中打开</a>

  3. _parent:在父框架中打开链接(如果页面在一个 <iframe> 中嵌套显示)。

<a href="example.html" target="_parent">在父框架中打开</a>

  4. _top:在最顶层窗口中打开链接,通常用于突破嵌套的 <iframe> 并覆盖整个浏览器窗口。

<a href="example.html" target="_top">在最顶层窗口中打开</a>

  5. 自定义窗口名称:你可以指定一个自定义名称,将链接打开到指定名称的窗口中,如果该窗口不存在,浏览器将创建一个新的窗口。

<a href="example.html" target="myWindow">在名为 myWindow 的窗口中打开</a>

target="_blank" 的意义

target="_blank" 指示浏览器在新标签页或新窗口中打开链接内容,用户的原页面不会被覆盖,常用于防止用户离开当前页面。

示例:

<a href="https://example.com" target="_blank">打开 example.com</a>

当用户点击这个链接时,https://example.com 将会在新标签页中打开。

注意事项

使用 target="_blank" 时,建议也设置 rel="noopener noreferrer" 属性,以防范安全漏洞,避免新页面可以访问你当前页面的 window 对象。

<a href="https://example.com" target="_blank" rel="noopener noreferrer">打开 example.com</a>

这个组合会提升安全性,特别是在涉及外部链接时。

 

2、关于音频标签<audio></audio>、需要要注意的点【controls loop autoplay】

<body>
  <!-- 在 HTML5 里面,如果属性名和属性值完全一样,可以简写为一个单词 -->  # 记住
  <audio src="./media/music.mp3" controls loop autoplay></audio>
</body>

 

3、关于视频标签<video></video>,需要注意的点【controls loop muted autoplay】

<body>
  <!-- 在浏览器中,想要自动播放,必须有 muted 属性 -->
  <video src="./media/vue.mp4" controls loop muted autoplay></video>
</body>

 

 

 

 

 

 
posted @ 2024-09-21 18:55  AlphaGeek  阅读(11)  评论(0)    收藏  举报