我在侧边栏中使用 Superfish 菜单,在悬停时动态显示其子菜单选项。由于各种原因,我需要动态创建子/子菜单元素,这会为“可抓取性”和良好的 SEO 带来问题。
有人对如何克服这个障碍有一些想法吗?我担心在页面加载时创建子菜单选项并简单地将它们隐藏直到悬停会造成 SEO 混乱,但我需要在抓取页面时搜索机器人可以访问这些链接,并创建好的站点地图。
谢谢!
用于动态子菜单的代码:
$(document).ready(function(){
var id;
var visits = 0;
var arrCounties = ["cities1.txt","cities2.txt","cities3.txt","cities4.txt","cities5.txt","cities6.txt","cities7.txt","cities8.txt","cities9.txt"];
var page = "-page-url.aspx";
for(id=0;id<arrCounties.length;id++){
$('#smItem_'+id).append("<ul id='submenu_"+id+"' class='seo_submenu'></ul>");
$.ajax({
type: "GET",
url: "http://www.domain.com/COUNTIES/"+arrCounties[id],
async: false,
success: function(data){
var cities = data.split("\r\n");
for(var i=0;i<cities.length;i++){
var cName = cities[i].substr(0,cities[i].indexOf(','));
cName = cName.replace(/\s+/g,'-');
$('#submenu_'+id).append("<li class='current'><a class='cityLinks' href='http://www.domain.com/location/" + cName + page + "'>"+cities[i]+"</a></li>");
}
}
});
}
});