问题描述
索引。这是我最初的想法,但这是不正确的。在这个问题下面阅读我的答案。
这是我试过的:
$(function(){
$('。testimonials')。html('test');
});
我已经无法在SO和网络上找到这个解决方案。 / p>
非常感谢任何帮助完成这一点。
提前感谢
搜索很久以后,我终于从Google支持小组自己找到了这个页面:. That was my initial thought, but this is incorrect. Read my answer below this question.
This is what I tried:
$(function () {
$('.testimonials').html('test');
});
I've been unable to find a solution for this around here in SO and around the web.
Any help to accomplish this is greatly appreciated.
Thanks in advance,
After searching for a long time I finally found this page from Google Support themselves: Can Google Site Search index JavaScript content on my pages?
This is exactly what they say in that page... short answer: No, it cannot index content inside JavaScript:
"Google Custom Search can't index content contained in JavaScript. The general rule for making sure that a web page can be indexed by Google is to ensure that all of the text that needs to be indexed is visible in a text-based browser, or a browser with JavaScript turned off."
So my initial assumption was right.
EDIT : "Google Custom Search" is the search service you put in your website, it's not www.google.com. However, I would assume that Google wouldn't use two separate engines, one for Custome Search and another one for www.google.com. But yes, that's just an assumption.
--
On the other hand I was wrong about something: DOM not getting changed. Ed Heal was right, the DOM is altered when the content from the JavaScript file is read by the browser. But again, even after this the content will not be indexed by search spiders.
svidgen pointed out something interesting, 'cloaking'. I hadn't thought of that.
After reading Google's examples of cloaking...:
- Serving a page of HTML text to search engines, while showing a page of images or Flash to users
- Inserting text or keywords into a page only when the User-agent requesting the page is a search engine, not a human visitor
...the solution I have is to just serve the testimonials via JavaScript and those visitors without JS just won't see that content, which is fine by us since the testimonials are not part of the core content of the page, they're only content enhancers. The main message of that page has already been said by the time they get to the testimonials, so no hurt in the content strategy.
Another thing that svidgen mentions that sounds very interesting is having the content fetched after a user-action is performed, that makes a lot sense, will certainly consider your suggestion.
If I have anymore information about this, I will certainly update this post with it.
Gave everyone an up-vote since everyone made very valuable comments/opinions.
Thanks all for your help! Greatly appreciated.
这篇关于注入内容/ HTML而不改变DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!