如何更新网页的某些部分?

时间:2022-10-07 16:31:49

I would like to update (change the content) some part of the webpage without updating the whole page (without refreshing the page). Of course first thing you would write as an answer will be "Ajax!!!", but I know that search engines will not be able to get the content of that part if I do with Ajax.

我想更新(改变内容)网页的一部分而不更新整个页面(不刷新页面)。当然,你首先要写的答案是“Ajax!!!”但我知道,如果我使用Ajax,搜索引擎将无法获得该部分的内容。

So is there any method or workaround to update page partly still remaining that part visible to the search engines?

那么,有什么方法或变通的办法来更新页面,部分仍然保持搜索引擎可见的部分?

3 个解决方案

#1


5  

yes.. it is possible by not using ajax ;)

是的. .不使用ajax是可能的;)

what you can do is load all content that is necessary for displaying. When the page is fully loaded you hide the content that should not be visible at startup. This can be done by CSS or javascript. When the content should be loaded by pressing a button you can alter the css property (with javascript) of the element so it is visible

您可以做的是加载所有显示所需的内容。当页面完全加载时,您将隐藏在启动时不应该可见的内容。这可以通过CSS或javascript来实现。当内容应该按一个按钮加载时,您可以修改元素的css属性(使用javascript),这样就可以看到了。

#2


2  

In short: No.

简而言之:没有。

The moment you start breaking the "One URL" = "One Page" principle, you alienate search engines (and bookmarkers, and people who want to send a link to a friend).

一旦你开始打破“一个URL”=“一个页面”的原则,你就疏远了搜索引擎(和书签,以及那些想给朋友发送链接的人)。

The other main option is frames (which replaces "invisible to search engines" with "orphan pages").

另一个主要选项是框架(用“孤儿页面”代替“不可见的搜索引擎”)。

A third option is stuffing all the content on to the page in the first place, and then using JS to set class names on elements to hide some content.

第三个选项是将所有内容填充到页面上,然后使用JS在元素上设置类名以隐藏某些内容。

In general, sharing duplicate meta-content (navigation etc) between pages is the cleanest, simplest, most reliable approach.

通常,在页面之间共享重复的元内容(导航等)是最干净、最简单、最可靠的方法。

#3


0  

I would put in normal links to normal pages and have javascript replace the link with the ajax link.

我将放入到普通页面的普通链接,并让javascript用ajax链接替换链接。

That way you are also providing for the people who have javascript disabled.

这样,您也为禁用了javascript的人提供了支持。

#1


5  

yes.. it is possible by not using ajax ;)

是的. .不使用ajax是可能的;)

what you can do is load all content that is necessary for displaying. When the page is fully loaded you hide the content that should not be visible at startup. This can be done by CSS or javascript. When the content should be loaded by pressing a button you can alter the css property (with javascript) of the element so it is visible

您可以做的是加载所有显示所需的内容。当页面完全加载时,您将隐藏在启动时不应该可见的内容。这可以通过CSS或javascript来实现。当内容应该按一个按钮加载时,您可以修改元素的css属性(使用javascript),这样就可以看到了。

#2


2  

In short: No.

简而言之:没有。

The moment you start breaking the "One URL" = "One Page" principle, you alienate search engines (and bookmarkers, and people who want to send a link to a friend).

一旦你开始打破“一个URL”=“一个页面”的原则,你就疏远了搜索引擎(和书签,以及那些想给朋友发送链接的人)。

The other main option is frames (which replaces "invisible to search engines" with "orphan pages").

另一个主要选项是框架(用“孤儿页面”代替“不可见的搜索引擎”)。

A third option is stuffing all the content on to the page in the first place, and then using JS to set class names on elements to hide some content.

第三个选项是将所有内容填充到页面上,然后使用JS在元素上设置类名以隐藏某些内容。

In general, sharing duplicate meta-content (navigation etc) between pages is the cleanest, simplest, most reliable approach.

通常,在页面之间共享重复的元内容(导航等)是最干净、最简单、最可靠的方法。

#3


0  

I would put in normal links to normal pages and have javascript replace the link with the ajax link.

我将放入到普通页面的普通链接,并让javascript用ajax链接替换链接。

That way you are also providing for the people who have javascript disabled.

这样,您也为禁用了javascript的人提供了支持。