使用 html 在同一选项卡中打开链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44884990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Opening a link in the same tab with html
提问by pepito
I want to open a link in the same tab with html when clicking a word. Nevertheless, even if I've tried it using target="_self
" and not using any target, it only works with target="_blank"
, but, as you may know, this opens the link in another tab.
单击单词时,我想用 html 在同一个选项卡中打开一个链接。尽管如此,即使我尝试使用target="_self
" 而没有使用任何目标,它也只能与 一起使用target="_blank"
,但是,如您所知,这会在另一个选项卡中打开链接。
Code:
代码:
<!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>
回答by O.Rares
<a target="_self" href="https://www.youtube.com" >YT player</a>
Use _self
用 _self
<a target="_self" href="https://www.youtube.com" >YT player</a>
回答by Manny Fresh
I'm sure you might have figured it out by now (over a year later), but your code:
我相信您现在(一年多后)可能已经想通了,但是您的代码:
<a target="_self" href="https://www.youtube.com" >YT player</a>
<a target="_self" href="https://www.youtube.com" >YT player</a>
is written a bit strange. Try:
写的有点奇怪。尝试:
<a href="https://www.youtube.com" target="_self">YT player</a>
<a href="https://www.youtube.com" target="_self">YT player</a>
回答by Bolphgolph
This works for me:
这对我有用:
<p><a href="https://www.youtube.com">YT-Player</a></p>