一行代码生成SiteMap

| |
[多云 2007/12/25 11:37 | by alex ]

请复制下面的内容到地址栏上敲回车:)

引用
javascript:var u=document.location.href;var t=prompt('输入更新时间:\n\n\n','');var p=prompt('输入索引等级:\n\n\n','1.0');var c=prompt('输入更新频率:\n\n\n','Always');var l=document.links;var s='<urlset%20xmlns="http://www.google.com/schemas/sitemap/0.84">\n';for(var i=0;i<l.length;i++){s+='<url>\n<loc>'+l[i]+'</loc>\n<lastmod>'+t+'</lastmod>\n<changefreq>'+c+'</changefreq>\n<priority>'+p+'</priority>\n</url>\n';}s+='</urlset>';clipboardData.setData('text',s);alert('以复制到剪切板');



原理很简单,用javascript脚本代码提取当前页面内所有链接并生成标准的Google SiteMap格式源代码。建议你保存这个链接到快捷栏上,使用方法就像del.icio.us的那个快捷操作一样,在你站点内任何页面下执行这个脚本后,SiteMap代码就会自动生成并保存在你的剪切板中,粘贴到记事本保存为utf-8编码,你也可以将多个页面下的代码合成到一起,不过不要超过100k

ps:鄙视一下Google,在Google中你无法搜索单引号双引号空格等字符,因为google认为这些字符没有实际意义,所以搜索也没用。这我都认了,但是搜索如&#8217;(单引号)&#32;(空格)这些HTML元字符集时也是不行的,google会给你返回空页面,但现时中Web开发人员的确有可能需要搜索这些字符的。当然,baidu也好不了哪里去,搜索&#32;返回给你的只是32的搜索结果:(

Tags: ,
网站建设 | 评论(0) | 引用(0) | 阅读(237)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]