Flash W3C valid and search engine friendly

Detect and embed Flash in XHTML

Tired of having Websites not listed on search engines like Google, Yahoo or MSN? Wanna have valid W3C standard code on your Website including Flash objects? This is where xSWF comes in.

First of all we need to find out what's up with Flash on the client site. Easy going, thanks to Flash Player Detection Kit from Adobe (formerly Macromedia). JavaScript function JSGetSwfVer gathers basic information about the plug-in, while the DetectFlashVer Function returns has right version or even is installed.

Secondly we're up to see what we can do for W3C compatiblity. Our way doing this is to forget things about the "embed" tag and handle the "object" tag in standard code. Here's our XHTML deal:

<object
type="application/x-shockwave-flash"
data="http://www.hofmanns.net/movie.swf?hl=en&m=index"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=6,0,0,0" width="400" height="300">
<param name="allowScriptAccess" value="sameDomain"/>
<param name="movie"
value="http://www.hofmanns.net/movie.swf?hl=en&m=index"/>
<param name="loop" value="false"/>
<param name="menu" value="false"/>
<param name="quality" value="high"/>
<param name="play" value="false"/>
<p style="text-align:center;">
<a href="http://www.macromedia.com/go/getflash/">
<img src="http://www.hofmanns.net/get-flash-player.gif"
alt="Macromedia Flash Player" style="border:none;"/></a>
</p>
<noscript>
Sorry your Browser isn't able to play Flash.
</noscript>
</object>

The most important thing adapting the source code on individual Websites is to make sure that "data" holds the same value (fqdn = fully qualified domain name) as the param "movie" did - and - the "codebase" points to Macromedia's Flash download page. That works great in all browsers and we've no need for the redundant "embed" tag.

Third, there's no job been done if you forgot Google, Yahoo, MSN, etc. Search engines only read the noscript part of the Flash plug-in - no big deal. The following source code shows how Flash with JavaScript and CSS can be optimized in a search engine friendly way:

xSWF v2.1 build 1905: http://www.hofmanns.net
xSWF Copyright (C) since 2003 by Karl Hofmann, Am Wimhof 73, D-94034 Passau, Germany (DE)

<!--
// xSWF 2.1 :: Flash W3C valid support, detect & embed Flash Objects
// :: search engine friendly optimization
//
// Copyright © since 2003 Karl Hofmann,
// http://www.hofmanns.net - All rights reserved.
//
// -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<script type="text/javascript" src="http://www.hofmanns.net/flash-player-detection-kit.js"></script>
<script type="text/javascript" src="http://www.hofmanns.net/x-shockwave-flash-object.js"></script>
<style type="text/css">
<!--
#object-layer {position:absolute; width:100%; height:100%; left:0; top:0;}
//-->
</style>
</head>
<body>
<div id="object-layer">
<p>Everything here shows up when JavaScript is disabled or
a Crawler like Google, Yahoo or MSN spiders the site</p>
</div>
<script type="text/javascript">
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if (hasRightVersion || noFlashInstalled) {
var fx = new com.xSWF("movie.swf", "hl=en&m=index", "Flash");
fx.write("object-layer");
} else {
<!--//
/*<![CDATA[*/
var getFlashPlayer =
'<a href="http://www.macromedia.com/go/getflash/">'+
'<img src="http://www.hofmanns.net/get-flash-player.gif" alt="Macromedia Flash Player"/></a>';
document.write(getFlashPlayer);
/*<]]>*/
//-->
}
</script>
</body>
</html>

This program is copyright software; you should have received a copy of the General License along with this program; if not, write to Karl Hofmann, Am Wimhof 73, D-94034 Passau, Germany (DE)

You are welcome to use or redistribute it under certain conditions; for the use of the software within a website the author note must be invariably taken over, please contact, for use going beyond that, Karl Hofmann for further details.

The JavaScript function fx needs to be set by the parameter of the Flash file, additional parameters for controlling issues (optional), the "ID" of the Flash object (optional) and overwrites the "div" layer of the same name with the instruction fx.write("object-layer"). Thus, not contents of the "div" tags are shown, but the Flash file.

The JavaScript function xSWF x-shockwave-flash-object.js version 2.1 is used to optimize crawling and indexing by search engines.

Č
ċ
ď
flash-player-detection-kit.js
(2k)
Charly Hofmann,
May 20, 2010 11:55 PM
ċ
ď
x-shockwave-flash-object.js
(3k)
Charly Hofmann,
May 21, 2010 12:04 AM