通过JavaScript隐藏Google的链接 [英] Hide links from Google via JavaScript

查看:58
本文介绍了通过JavaScript隐藏Google的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些我们想对Google隐藏的链接,使用Javascript隐藏"链接,但让其适用于实际的客户端.

We have some links we want to hide from Google, using Javascript to "hide" the link but let it work for the real clients.

从SEO代理商那里得知,最好的方法是对链接进行base64编码并通过javascript对其进行调用:

I was told from the SEO agency that the best method is to base64 encode the link and call it via javascript:

<a data-href="RdcDovL1N0YWdpbmc...base64...hhcmRpbmctaGVycmVuLWhlbaQtMTgyMDg3"
   href="#">Link</a>


<script>
<!--
var _dlist = document.getElementsByTagName('A');
for(i=0;i<_dlist.length;i++) {
    var _data = _dlist[i].getAttribute( 'data-href' );
    if( _data !== 'null' ) {
        var _extend = CryptoJS.enc.Base64.parse( _data );
        _dlist[i].setAttribute( 'href', _extend.toString( CryptoJS.enc.Latin1 ) );
    }
}
-->
</script> 

我现在的问题是,我不想只为链接添加另外2个文件(它们向我建议crypto-js lib).我想问你,Google展示链接并跟踪链接有多远,什么是最简单的方法而不加载更多脚本.jQuery可用.

My problem now is, I don't want to include another 2 files (they suggested me crypto-js lib) just for the links. I'd like to ask you, how far does Google reveal links and follow them and what's the easiest approach without loading more scripts. jQuery is available.

推荐答案

这就是我最终得到的结果:

This is what I ended up with:

链接看起来像:

<a href="#" onclick="linkAction(this); return false;" 
   data-href="uggc://fgntvat.....">

其中 data-href 是Rot13编码的,而 linkAction 则是:

Where data-href is Rot13 encoded and linkAction does:

function linkAction(e) {
    window.location = rot13($(e).data('href'));
}

..位于外部JS文件中.

..in an external JS file.

我认为这是最好的方法,不会增加性能开销.让我们看看SEO代理商说的是什么:-)

I think this is the best obfuscation without performance overhead. Let's see what the SEO agency says :-)

PS Rot13来自:我的JavaScript中rot13的单行实现在哪里出错?

P.S Rot13 taken from: Where is my one-line implementation of rot13 in JavaScript going wrong?

这篇关于通过JavaScript隐藏Google的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆