Home > Web Front-end > HTML Tutorial > Flash embedded in html Solution for embedding Flash files in HTML web page code (Part 2)_HTML/Xhtml_Web page production

Flash embedded in html Solution for embedding Flash files in HTML web page code (Part 2)_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:40:32
Original
1509 people have browsed it

Regarding the use process of my SWFObject V1.5, I have come to an end with the introduction in the previous part . Now I will lead SWFObject V2.1 to meet you. If I had gotten to know V2.1 earlier, If so, you may not be bothered by the "waiting for HTML DOM to load" problem.
First of all, let me give you a brief introduction to the calling example of V2.1 syntax:


Copy code The code is as follows:



Personally, I prefer the third way of writing above. As will be mentioned below, I embed Flash in the HTML code The final solution of the file is to adopt the third style of calling swfobject.embedSWF(). The style of the V2.1 version is very consistent with the style of modern JS, and the code appears more concise.

The solution adopted in the previous article seems to be able to meet most needs, and the compatibility seems to be decent. It should be able to meet the needs of most friends, and it may not be a decent solution. . However, there is a relatively extreme situation that I discovered, which is:

Copy the codeThe code is as follows:
new SWFObject("http://www.pec365.com/Flash/20071113.swf", "mymovie", "304", "367", "7", "#FFFFFF");

, if the address of the incoming Flash file is wrong, or the Flash file is deleted from the server, then you will see a situation you least want to see, example
As follows:


Copy the codeThe code is as follows:

DEMO












It is recommended that you execute this code yourself. If you are a novice, you can refer to the steps introduced in the previous article to run this code and truly feel the "disaster" coming.

Yes, you will see that the page is blank, and the image that was originally used to replace the backup when Flash cannot be displayed is also missing. Where did it go? After debugging, I found that even if the incoming Flash file address is wrong, a wrong tag will be created and the
[… …]
is replaced with the content in it, so that what you see will form a blank area with a height and width of 304px and 367px respectively (if Flash player is installed, right-click the mouse in the upper left corner of the screen, you Something will be discovered), so the nightmare comes.

In order to solve this nightmare result, I came up with a bad idea. First, check whether the file really exists on the server based on the incoming Flash file address. If the returned result is the If the Flash file exists, then execute the swfobject.embedSWF() method, and the specific idea is to use the XMLHttpRequest object to request the server through GET/HEAD, and then determine that xmlHttp.status == 200 || xmlHttp.status == 302 exists as a file basis, but this method still seems to have certain flaws, and I am not yet able to improve it. Here is an example of my final solution:

Copy Code
The code is as follows:


DEMO

< script language="javascript" type="text/javascript" src="JavaScript/swfobject.js">




< ;div id="flashcontent">

Get Adobe Flash player


< /form>



Wow, I spent several hours tossing out these two texts, and I accidentally stayed in the company until the end It's 22 o'clock, and the security is here to chase people away. I want to end it hastily. I will carve out the text when I have free time at work tomorrow, haha.
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template