在上一帖子 中介绍了Ted的站点,关于其中的SEO技巧,结合自己的理解,详细说下。
相比一般的网页,SWF文件有个最大的问题就是:其中的文字、图片等数据无法被搜索引擎识别。因为SWF是以浏览器插件的形式运行的,而搜索引擎在抓取页面进行分析时,将忽略掉SWF文件的内容,除非它能够分析SWF文件的文件格式,这基本上是不可能的。特别是使用Flex或Flash制作的动态站点,比如Flash留言本,其中的留言信息虽然也显示出来,但是在SWF里面,搜索引擎无法找到这些信息,也就无法收录。
在这个搜索引擎当道的年代,这的确是个很大的问题,特别是一些商业站点,由于这个原因,很少会采用全flash站点,这样不利于网站推广。
而这个站点,把Flex中用到的数据全部写在HTML页面中,也就是以"div"的形式处理。 <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="http://directory.onflex.org/template003.xsl"?> <html> <head> <title>Flex Directory - The consulting directory for Adobe Flex</title> <meta name="Description" content="An open listing of consulting firms providing development services for Adobe Flex. Locate developers your your Flex projects."/> <meta name="Keywords" content="Adobe, Flex, ActionScript, Flash, consulting, development, services, outsourcing, RIA, Rich Internet Applications"/> </head> <div contact="mitch.olson@getoutsmart.com" url="www.getoutsmart.com" partner="1" country="NZ" location="Auckland NZ" developers="12">Outsmart</div> ... </head> </html> 这个HTML页面遵循XML格式,因此,可以被当作XML文件被加载。整个页面没有插入SWF文件,那swf文件从哪来?一切秘密都在http://directory.onflex.org/template003.xsl里面。注意 <?xml-stylesheet type="text/xsl" href="http://directory.onflex.org/template003.xsl"?>这句话,xsl是用来格式化xml数据,并构造页面表现的关键。
在http://directory.onflex.org/template003.xsl文件中,有这样一段代码:
<script type="text/javascript" src="http://directory.onflex.org/swfobject.js"></script>
<script type="text/javascript">
// <![CDATA[
function writeView(){
var so = new SWFObject( "http://directory.onflex.org/template003.swf" , "fxtxsl" , "100%" , "100%" , "9" , "#191919");
so.addParam( "scale" , "noscale" );
so.addVariable("xmlurl", document.location );
so.useExpressInstall( "http://directory.onflex.org/expressinstall.swf" );
so.write( 'flexcontent' );
document.getElementById('logger').src="/log.html"
} // ]]> </script>
<body scroll="no" onload="writeView()">
<div id="flexcontent"></div>
<iframe id="logger" style="visibility:hidden"/> </body>
这里使用swfObject写入swf文件,并传入了一个值xmlurl,也就是要加载的数据文件路径,然后flex加载主页面。这样xsl就把页面的显示层搭建出来了。
整个过程有点绕圈子。我只是对SEO有简单了解,欢迎朋友们交流。