Flash 嵌入的问题朋友们可能认为很简单,但是具体到一些问题上来讲,就不是那么简单了,比如:IE浏览器对FLASH的拦截虚框怎么去掉?在FF、OP、NS等其它浏览器是否兼容?代码是否符合W3C标准??等等
下面我就转贴别人的一篇文件,共同学习一下
一、传统的方法
这方法是使用 object 和 embed 标签来嵌入,细心的会发现,object 的很多参数和 embed 里面的很多属性是重复的,为什么这样做?为了浏览器兼容性,有的浏览器支持 object,有的支持 embed,这也是为什么要修改 Flash 的参数时两个地方都要改的原因。
这种方法是 Macromedia 一直以来的官方方法,最大限度的保证了 Flash 的功能,没有兼容性问题。但是它现在不那么好用了: 无法通过验证,由于为了兼容性而嵌入的 embed 标签是不符合 W3C 的规范的。当然,如果你不在乎什么规范不规范,另当别论。
微软由于种种原因,在 sp2 后限制了 IE 的 ActiveX 的使用模式,就是在页面中的 ActiveX 有一个虚框,需要用户点击一次才能正常交互。Flash是作为一个 ActiveX 嵌入到网页中的,所以它也会受牵连,只有通过 JS 嵌入 Flash 才能解决这个问题。
没有 Flash 版本检测,如果版本浏览器的flash插件版本不够,或者不能正常显示你的 swf 文件,或者会弹出一个 ActiveX 的确认安装的框——这个框对很多用户来说是很恐怖的。
二、用JS嵌入的方法
用JS嵌入就是各有各的嵌入方法了,有嵌得好的有嵌得不好的。有人用 document.write 直接写,这法子说实话不大好,感觉 hack 成分多了,有点为了验证而验证的意思,而且没有体现出什么 JS 的优势。我觉得一个好的 JS 嵌入脚本,在保证 Flash 应有功能的基础上,要发挥 JS 的优势应该要有版本检测,要能很好解决可访问性问题(也就是用户在无法浏览 Flash 内容或禁用 JS 的时候应该如何处理的问题),要易于重复使用。
我们这里要讲的是SWFObject这个解决方案:
“SWFObject”是利用Javascript 插入flash,好处多多,代码简洁,不会出现IE6下的“单击此处以激活控件”的提示,并且能通过W3C验证。不同于传统的“object”插入flash的方法。
SWFObject在新的2.x版本中,其最简单的调用竟只需一句话,并且不需要等待页面加载完成,这意味着你可以将这句话写在页面的任何地方。比以前的版本,要简便多了。下面来看几个简单常用的调用方法:
1、最简单,最基本,只要想插入flash都能用到的经典一句话。
<script></script>
<script><br>swfobject.embedSWF("test.swf", "swfid", "300", "120", "9.0.0", "expressInstall.swf"); <br></script>
注解:调用方法embedSWF——插入SWF文件,参数依次是@swf文件的地址;@用于装入swf文件的容器(如div)的id;@flash的宽度;@flash的高度(当然,这里的宽高都可以使用诸如100%这样的百分比来表示);@正常播放该flash所需的最低版本;@当版本低于要求时,执行该swf文件,这里利用这个flash跳转到官方下载最新版本的flash插件。(该参数可以省略)在同一个页面插入多个flash到不同位置时,只要重复上面的语句,使用不同的容器id就可以了。
2、给swf文件传递参数、变量、属性的调用方法
<script> <br>//1、使用Json初始化变量、参数、属性 <br> var flashvars = {<br> name1: "hello",<br> name2: "world",<br> name3: "foobar"<br> };<br> var params = {<br> menu: "false"<br> };<br> var attributes = {<br> id: "dynamicContent2",<br> name: "dynamicContent2"<br> };<br> swfobject.embedSWF("test6_flashvars.swf", "content2", "300", "120", "6.0.0","expressInstall.swf", flashvars, params, attributes); <br><br>//2、传统的初始化设置,效果一样 <br> var flashvars = {};<br> flashvars.name1 = "hello";<br> flashvars.name2 = "world";<br> flashvars.name3 = "foobar";<br> var params = {};<br> params.menu = "false";<br> var attributes = {};<br> attributes.id = "dynamicContent3";<br> attributes.name = "dynamicContent3";<br> swfobject.embedSWF("test6_flashvars.swf", "content3", "300", "120", "6.0.0","expressInstall.swf", flashvars, params, attributes); </script>
//3、直接写在后面,就一句话,简洁剽悍,不拖泥带水
swfobject.embedSWF("test6_flashvars.swf", "content5", "300", "120", "6.0.0","expressInstall.swf", {name1:"hello",name2:"world",name3:"foobar"}, {menu:"false"}, {id:"dynamicContent5",name:"dynamicContent5"});
SWFObject google 开源项目 http://code.google.com/p/swfobject/
SWFObject(2.2版) 下载地址:http://swfobject.googlecode.com/files/swfobject_2_2.zip
SWFObject(2.0版) 下载地址:http://swfobject.googlecode.com/files/swfobject_2_0.zip
SWFObject的官方Blog:http://blog.deconcept.com/swfobject/
SWFObject 2.0 官方文档(中文) http://www.admin10000.com/resource/1.html

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft