开发者

If I'm adding content in page through JavaScript will it be crawlable by Search engine spider

开发者 https://www.devze.com 2023-01-04 02:16 出处:网络
If I\'m adding content in page through JavaScript will it be crawl-able by Search engine spider and accessible by screen reader.

If I'm adding content in page through JavaScript will it be crawl-able by Search engine spider and accessible by screen reader.

For example 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(functio开发者_开发技巧n(){

    //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 Search engine but at the same time keep accessible by screen reader is it possible?


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


Short answer, probably not. But, Google is getting more sophisticated all the time, so I have my suspicions that they actually render Javascript as part of the indexing process.

Is there a particular reason to do it this way? I'd recommend doing this logic server-side if possible, then you know your HTML is readable by search engines.


Re: will content generated dynamically (on the browser) be crawlable by a search engine?

Normally, no.

But Google has invented a way to solve the problem. See ajax crawling

Note: they do it by crawling your urls with various query parameters representing the different states of the dynamic page. They do not attempt to run the js on your page.


No, most web crawlers do not execute JavaScript and older screen readers do not read it either. Your best bet would be to only use Javascript for presentation purposes and use the logic server side (PHP, Ruby, .NET, etc) and some CSS magic to achieve what you are trying to do above with the content. Always insert content via server side if you are concerned about web crawlers and screen readers, and use JavaScript for presentation only. Alternatively, you can use a Flash and JavaScript sniffer for screen readers to redirect the user to an alternate page that does not rely on dynamic content.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号