If I add content to the page via JavaScript, it will be crawled using a search engine

If I add content to the page via JavaScript, it will be crawled using a search engine and available for reading from the screen.

For an example of this

var tip = "<p>Most computers will open PDF documents ";
tip += "automatically, but you may";
tip += "need to download <a title='Link to Adobe website-opens in a new window'";
tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html'  
               target='_blank'>Adobe Reader</a>.</p>";

$(document).ready(function(){

    //IF NUMBER OF PDF LINKS IS MORE THAN ZERO INSIDE DIV WITH ID maincontent
    //THEN THIS WILL PUT TIP PARAGRAPH AS LAST CHILD OF DIV
    if($("div#maincontent a[href*='/pdf']").length>0){
    $("div#maincontent").children(":last-child").after(tip);
    }
});

Edit: I want to hide this from the search engine, but at the same time, is it possible to maintain access to it using a screen reader?

+3
source share
4 answers

It depends on the crawler, but don't expect most bots to interpret Javascript.

+2
source

, , . Google , , Javascript .

? , , , HTML .

+2

Re: ( ) ?

.

Google . . ajax

: URL- , . js .

+1

, - JavaScript, . Javascript (PHP, Ruby,.NET ..) CSS , . , - , JavaScript . , Flash JavaScript , .

0

Source: https://habr.com/ru/post/1751135/


All Articles