javascript - anchor 链接到外部站点并避免显示为使用 javascript 的引用站点或流量源

标签 javascript html seo anchor

我正在我的网站中添加指向外部网站的 anchor 链接。

<a href="externalwebsite.com"  rel="nofollow">external website</a>

这使我的网站显示为推荐网站和/或可能成为这些外部网站的流量来源。 一些网站管理员不喜欢这个(他们说这会影响他们的搜索引擎优化工作)并要求我删除链接。 我想避免这种情况。

有 Javascript 的解决方案吗? 谢谢

最佳答案

您可以尝试创建一个与类的空链接,然后让脚本运行 onload 以正确创建这些链接。

以下文章抄自:http://www.seomofo.com/ethics/using-javascript-to-hide-links.html

1. Remove affiliate links from your pages’ HTML code.
2. If it’s a text link embedded in page content, then just remove the <a> tags
    and leave the anchor text there (as plain text).
3. If it’s an image link, remove the <a> tags AND the <img> tag.
4. Replace the <a> tags with <span> tags, and assign a class name to them
    (e.g. <span class="affiliate">).
5. Write a JavaScript function that looks for <span> elements that contain 
    class="affiliate" and replaces them with your affiliate links. 
    (Yes, the ones you removed in Step 1).
6. Put the JavaScript function in an external .js file and block Google from \
    accessing it (using robots.txt).
7. Attach the JavaScript function to the onload event, which means users’ web 
     browsers won’t call the function until after the page is finished loading.
8. Googlebot–and users without JavaScript enabled–can’t call the JavaScript 
     function, so your affiliate links are never inserted into the page content.
9. Only users with JavaScript-enabled browsers will see your affiliate links. 
    Everything/everyone else sees plain text instead of affiliate text links, 
    and an empty space instead of affiliate image links.

关于javascript - anchor 链接到外部站点并避免显示为使用 javascript 的引用站点或流量源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15726247/

相关文章:

android - 如何在没有webview的情况下在android中显示HTML内容

.htaccess - htaccess 重定向友好获取文件

c# - Page_ClientValidate() 对象预期错误,无法找到验证器

javascript - 带日期选择器的简单对话框

javascript - 使用 chrome.cookies 扩展响应 cookie 和 2 个异步 xmlhttp 请求

html - CSS: :after 是否可以有一个不间断的空间?

javascript - 根据选择控件的值查找选项文本

iphone - 使 iPhone 字体大小与其他浏览器相同

asp.net-mvc - ajax 获取 http 请求的 url 应该对 seo 友好吗?

angularjs - angular-route 如何防止第一次下载,但稍后允许