[英]How do I add 'nofollow' link in java script
I tried in this way but it is not working: 我以这种方式尝试过,但是没有用:
Java Script:
<script type="text/javascript">
function DoNav(theUrl)
{
document.location.href = theUrl;
}
</script>
Php code:
echo " onclick=\"DoNav('https://www.example.com/profile.php?id={$profile_id}'rel='nofollow');\">\n";
nofollow concerns a classic link, not for a link opened on JS. nofollow关注经典链接,而不是针对在JS上打开的链接。 It's for search engine robots.
适用于搜索引擎机器人。
// Will indicate a robot that it does not have to follow this link
<a href="http://www.link.com" rel="nofollow"></a>
// If your action is JS opened you don't care to set nofollow, robots won't go on it.
<a href="#" onclick="window.open('http://www.link.com');"></a>
If you just want to prevent robot from accessing a particular adress on your website, you should use robots.txt : http://robots-txt.com/ 如果您只是想防止漫游器访问您网站上的特定地址,则应使用robots.txt: http : //robots-txt.com/
If you just don't want google to access your particular page profile.php, You can ad this in robots.txt : 如果您只是不想让Google访问您的特定页面profile.php,可以在robots.txt中投放:
User-agent: Googlebot
Disallow: profile.php
And you can use classic links instead of JS ones, and add nofollow too : 而且您可以使用经典链接而不是JS链接,并添加nofollow:
<a href="./profile.php?id={$profile_id}" rel="nofollow">...</a>
You don't need to open it with JS 您不需要用JS打开它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.