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
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
head>
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:
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.
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