使用 html 在同一选项卡中打开链接

新手上路,请多包涵

单击一个单词时,我想在与 html 相同的选项卡中打开一个链接。尽管如此,即使我尝试使用 target="_self “ 并且不使用任何目标,它也只能与 target="_blank" 一起使用,但是,如您所知,这会在另一个选项卡中打开链接.

代码:

     <!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
  min-width:360px;
}
a{
   color:#009900;
   text-decoration:none;
}
a:hover
{
  text-decoration:underline;
}
p
{
  font:0.8em sans-serif;
}
h1
{
  font:1.5em sans-serif;
  color:#fff;
  background:#006600;
  padding:5px
}
</style>
</head>

<body>
  <h1>play</h1>
 <p><a href="https://www.youtube.com" target="_blank">YT player</a></p>
</body>
</html>

原文由 pepito 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 374
2 个回答
 <a target="_self" href="https://www.youtube.com" >YT player</a>

使用 _self

 <a target="_self" href="https://www.youtube.com" >YT player</a>

原文由 O.Rares 发布,翻译遵循 CC BY-SA 4.0 许可协议

我确定您现在(一年多后)可能已经弄清楚了,但是您的代码:

<a target="_self" href="https://www.youtube.com" >YT player</a>

写的有点奇怪。尝试:

<a href="https://www.youtube.com" target="_self">YT player</a>

原文由 Manny Fresh 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏