Dmytro Zarezenko
Dmytro Zarezenko

Reputation: 10686

Prevent URLs form JavaScript array from Google indexation

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.

Upvotes: 1

Views: 224

Answers (1)

Pierre
Pierre

Reputation: 1282

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');
});

Upvotes: 1

Related Questions