﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Albert's 实践记录-文章分类-Web</title><link>http://www.blogjava.net/ouxingning/category/42268.html</link><description>Java、Perl、Shell、&amp; ……</description><language>zh-cn</language><lastBuildDate>Wed, 21 Oct 2009 22:36:47 GMT</lastBuildDate><pubDate>Wed, 21 Oct 2009 22:36:47 GMT</pubDate><ttl>60</ttl><item><title>页面中嵌入Flash的相关问题</title><link>http://www.blogjava.net/ouxingning/articles/xhtml_flash_swfobject.html</link><dc:creator>ouxingning</dc:creator><author>ouxingning</author><pubDate>Tue, 20 Oct 2009 09:31:00 GMT</pubDate><guid>http://www.blogjava.net/ouxingning/articles/xhtml_flash_swfobject.html</guid><wfw:comment>http://www.blogjava.net/ouxingning/comments/299078.html</wfw:comment><comments>http://www.blogjava.net/ouxingning/articles/xhtml_flash_swfobject.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ouxingning/comments/commentRss/299078.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ouxingning/services/trackbacks/299078.html</trackback:ping><description><![CDATA[今天有一个项目上线测试，发现很多页面在IE下报错，出错的意思大概都是&#8220;null为空或不是对像&#8221;，使用IE的调试工具调试了一下，出错的位置为：<br />
<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">try</span><span style="color: #000000;">&nbsp;{&nbsp;document.getElementById(</span><span style="color: #000000;">""</span><span style="color: #000000;">).SetReturnValue(__flash__toXML(document.location.protocol.valueOf())&nbsp;)&nbsp;);&nbsp;}&nbsp;</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">&nbsp;(e)&nbsp;{&nbsp;document.getElementById(</span><span style="color: #000000;">""</span><span style="color: #000000;">).SetReturnValue(</span><span style="color: #000000;">"</span><span style="color: #000000;">&lt;undefined/&gt;</span><span style="color: #000000;">"</span><span style="color: #000000;">);&nbsp;}</span></div>
<br />
原因应该是<span style="color: #000000;">document.getElementById(</span><span style="color: #000000;">""</span><span style="color: #000000;">)获取不到内容，由于大部分页面都使用&lt;object/&gt;标签嵌入了一个Flash，</span>而且&lt;object/&gt;标签内没有id属性，于是在&lt;object/&gt;标签里添加一个id，问题解决了。<br />
<br />
对于在页面里嵌入Flash，更常见的做法是使用SWFObject，转一篇SWFObject的官方文档（<a href="http://code.google.com/p/swfobject/wiki/documentation" target="_blank">http://code.google.com/p/swfobject/wiki/documentation</a>），<a href="http://farthinker.cn/documents/swfobject-2-documentation/" target="_blank">中文</a>。<br />
<br />
<h2><a name="What_is_SWFObject?">What is SWFObject?</a></h2>
<p><a name="What_is_SWFObject?">SWFObject 2: </a></p>
<ul>
    <li><a name="What_is_SWFObject?">Offers two optimized Flash Player embed methods; a markup based approach and a method that relies on JavaScript </a></li>
    <li><a name="What_is_SWFObject?">Offers a </a><a href="http://code.google.com/p/swfobject/wiki/api" rel="nofollow">JavaScript API</a> that aims to provide a complete tool set for embedding SWF files and retrieving Flash Player related information </li>
    <li>Utilizes only one small JavaScript file (10Kb / GZIPed: 3.9Kb) </li>
    <li>Is the successor of <a href="http://blog.deconcept.com/swfobject/" rel="nofollow">SWFObject 1.5</a>, <a href="http://www.bobbyvandersluis.com/ufo/" rel="nofollow">UFO</a> and the <a href="http://www.adobe.com/products/flashplayer/download/detection_kit/" rel="nofollow">Adobe Flash Player Detection Kit</a> </li>
    <li>Intends to unify all existing Flash Player embed methods and provide a new standard for embedding Adobe Flash Player content </li>
</ul>
<h2><a name="Why_should_you_use_SWFObject?">Why should you use SWFObject?</a></h2>
<p><a name="Why_should_you_use_SWFObject?">SWFObject 2: </a></p>
<ul>
    <li><a name="Why_should_you_use_SWFObject?">Is more optimized and flexible than any other Flash Player embed method around </a></li>
    <li><a name="Why_should_you_use_SWFObject?">Offers
    one solution for everybody: It shouldn't matter if you are an HTML,
    Flash, or JavaScript developer, there should be something in it for
    everyone </a></li>
    <li><a name="Why_should_you_use_SWFObject?">Breaks the cycle of being locked into vendor specific markup and promotes the use of web standards and alternative content </a></li>
    <li><a name="Why_should_you_use_SWFObject?">Uses unobtrusive JavaScript and JavaScript best practices </a></li>
    <li><a name="Why_should_you_use_SWFObject?">Is easy to use </a></li>
</ul>
<p><a name="Why_should_you_use_SWFObject?">The A List Apart article </a><a href="http://www.alistapart.com/articles/flashembedcagematch/" rel="nofollow">Flash Embedding Cage Match</a> describes the full rationale behind SWFObject 2. </p>
<h2><a name="Why_does_SWFObject_use_?">Why does SWFObject use JavaScript?</a></h2>
<p><a name="Why_does_SWFObject_use_?">SWFObject 2 primarily uses JavaScript to overcome issues that cannot be solved by markup alone; it: </a></p>
<ul>
    <li><a name="Why_does_SWFObject_use_?">Detects
    the Flash Player version and determines whether Flash content or
    alternative content should be shown, to avoid that outdated Flash
    plug-ins break Flash content </a></li>
    <li><a name="Why_does_SWFObject_use_?">Offers
    functionality to revert to alternative content in case of an outdated
    plug-in by means of a DOM manipulation (Note: if no Flash plug-in is
    installed the HTML <tt>object</tt> element automatically falls back to its nested alternative content)  </a></li>
    <li><a name="Why_does_SWFObject_use_?">Offers the option to use Adobe Express Install to download the latest Flash Player </a></li>
    <li><a name="Why_does_SWFObject_use_?">Offers a JavaScript API to perform common Flash Player and Flash content related tasks  </a></li>
</ul>
<h2><a name="Should_I_use_the_static_or_dynamic_publishing_method?">Should I use the static or dynamic publishing method?</a></h2>
<p><a name="Should_I_use_the_static_or_dynamic_publishing_method?">SWFObject 2 offers two distinct methods to embed Flash Player content: </a></p>
<ol>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The <strong>static publishing method</strong>
    embeds both Flash content and alternative content using standards
    compliant markup, and uses JavaScript to resolve the issues that markup
    alone cannot solve </a></li>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The <strong>dynamic publishing method</strong>
    is based on marked up alternative content and uses JavaScript to
    replace this content with Flash content if the minimal Flash Player
    version is installed and enough JavaScript support is available
    (similar like previous versions of SWFObject and UFO) </a></li>
</ol>
<p><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The advantages of the <strong>static publishing method</strong> are: </a></p>
<ol>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The actual authoring of standards compliant markup is promoted </a></li>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">Best embed performance </a></li>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The
    mechanism of embedding Flash content does not rely on a scripting
    language, so your Flash content can reach a significant bigger
    audience: </a></li>
    <ul>
        <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">If
        you have the Flash plug-in installed, but have JavaScript disabled or a
        use a browser that doesn't support JavaScript, you will still be able
        to see your Flash content </a></li>
        <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">Flash will now also run on a device like Sony PSP, which has very poor JavaScript support </a></li>
        <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">Automated tools like RSS readers are able to pick up Flash content  </a></li>
    </ul>
</ol>
<p><a name="Should_I_use_the_static_or_dynamic_publishing_method?">The advantages of the <strong>dynamic publishing method</strong> are: </a></p>
<ol>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">It integrates very well with scripted applications and enables the use of dynamic variables (flashvars) </a></li>
    <li><a name="Should_I_use_the_static_or_dynamic_publishing_method?">It avoids <em>click-to-activate mechanisms</em> to activate <em>active content</em> in Internet Explorer 6/7 and Opera 9+. Please note that Microsoft </a><a href="http://blogs.msdn.com/ie/archive/2007/11/08/ie-automatic-component-activation-changes-to-ie-activex-update.aspx" rel="nofollow">has phased out most active content</a> from its Internet Explorer browsers </li>
</ol>
<a name="What_is_SWFObject?"><br />
</a>
 
<img src ="http://www.blogjava.net/ouxingning/aggbug/299078.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ouxingning/" target="_blank">ouxingning</a> 2009-10-20 17:31 <a href="http://www.blogjava.net/ouxingning/articles/xhtml_flash_swfobject.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>