Prevent URLs form JavaScript array from Google indexation

Deadly 提交于 2020-01-05 07:56:21

问题


I have some adverts on my site. This adverts are images and not closed in <a> tag. I store adverts URLs in JS array advertisement. When user clicks on advert the next JS code executed:

    $(".jLinkBlank").click(function() {
        var adverId = parseInt($(this).attr('id').substring(5));
        var url = advertisement[adverId];
        window.open(url, '_blank');
    });

But as I see Google indexing such URLs in any case. How can I prevent such URLs from Google indexation?

Solutions like robots.txt or <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> are not acceptable, because URLs list is dynamic and I have other URLs on the pages what must be indexed by Google.


回答1:


You can try to encode your uri in base64 and decode them when adding them to page :

You can use btoa to decode a base 64 string, atob to encode.

$(".jLinkBlank").click(function() {
     var adverId = parseInt($(this).attr('id').substring(5));
    var url = btoa(advertisement[adverId];)
    window.open(url, '_blank');
});


来源:https://stackoverflow.com/questions/15659419/prevent-urls-form-javascript-array-from-google-indexation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!