问题描述
|
jQuery模式对话框SEO友好吗?如果不能,我们可以进行哪些更改,以便爬网程序可以轻松读取模式对话框中的内容?
提前致谢。
编辑:抱歉忘了提及模态中的内容来自服务器端。所以它也使用ajax。
解决方法
如果您的对话框内容仅存在于页面中并且被“变成了jquery模态对话框”,那么它将成为爬虫可以访问的部分数据...如果内容是通过ajax等加载的,则不会\不会被索引,因为它需要运行javascript来填充html。
...
<body>
<div id=\"MyModalDialog\">
This is content I want the search engine to index. As it exists in the page without needing any javascript to exist here,it could be indexed.
</div>
<input value=\"Show Dialog\" id=\"ShowDialog\" />
</body>
...
编辑
如果内容以任何方式都需要javascript,并且还不是原始请求的一部分,那么您基本上可以假定搜寻器不会将其编入索引。
编辑2
如果您想采取策略来克服这一点。如果您使用html链接打开对话框,并提供了正确打开URL的链接,那么对于未启用javascript的浏览器/客户端/抓取工具,您总是会遇到一个后备问题,然后可以对该内容进行索引...但是会在原始网址下建立索引...您可能不希望人们进入您的网站的网址...
像这样:
<div id=\"dialog\">
</div>
<a href=\"/page/to/index/content\" class=\"open-dialog\">Open Dialog</a>
和脚本
$(function() {
$(\"a.open-dialog\").click(function(e) {
e.preventDefault();
// get the url that this link is going to open
var url = $(this).attr(\"href\");
// put contents in div and show dialog
$(\"#dialog\").load(url).dialog({modal:true});
});
});
因此,抓取工具只会跟踪从a标签到其他内容的链接,并可能将其编入索引……希望这很有意义……否则,jQuery代码将取消链接单击,并在对话框中打开内容。