About my mit-licensed V1.5 using process, in the above article introduces temporarily, below I will lead mit-licensed V2.1 appearance to meet with you, if I had met earlier V2.1, might not be &other; Waiting for the HTML DOM is loaded &throughout; The problem of intrusion. First of all, give you a brief introduce V2.1 syntax to invoke the sample:

 


code is as follows:


<Script type="text/javascript 'SRC=" http://www.jb51.net//web/swfobject.js "> </script> <The script type="text/javascript" >//1, to use Json initializing variables, parameters, attributes, the var for flashvars={name1: "hello," name2: "world," name3: "foobar"}; Var params={menu: "false"}; Var attributes={id: "dynamicContent2," name: "dynamicContent2"}; Test6_flashvars. SWF mit-licensed. EmbedSWF (" ", "content2", "300", "120", "6.0.0", "expressInstall. SWF," for flashvars, params, attributes);//2, traditional initialization Settings, the same effect as the var for flashvars={}; For flashvars. Name1="hello"; For flashvars. Name2="world"; For flashvars. Name3="foobar"; Var params={}; Params. Menu="false"; Var attributes={}; The attributes. The id="dynamicContent3"; The attributes. The name="dynamicContent3"; Test6_flashvars. SWF mit-licensed. EmbedSWF (" ", "content3", "300", "120", "6.0.0", "expressInstall. SWF," for flashvars, params, attributes);//3, write directly on the back, in a word, concise and agile, don't slow mit-licensed. EmbedSWF (" test6_flashvars. SWF ", "content5", "300", "120", "6.0.0", "expressInstall. SWF," {name1: "hello," name2: "world," name3: "foobar"}, {menu: "false"}, {id: "dynamicContent5," name: "dynamicContent5"}); </script> Personally, I prefer the third kind of writing, the following is mentioned, I am in the HTML code to embed Flash files of the final solution, is to take the third style called mit-licensed. EmbedSWF (). V2.1 version of the style is very accord with the modern style of JS, the code is more concise. Last solution adopted in opinion, seems to have been able to meet the demand of most, and compatibility seems to also will get by, should be able to meet the needs of most friends, also have not cannot be a reasonable solution. However, there is a kind of extreme condition be I found, is in:

 


code is as follows:


new mit-licensed (" http://www.pec365.com/Flash/20071113.swf ", "mymovie", "304", "367", "7", "# FFFFFF"); , if the incoming Flash files address is wrong, or the Flash file is deleted in the server, then you will see one of the most don't want to see, the sample is as follows:

 


code is as follows:


<Html> <Title> DEMO <Head> <Script type="text/javascript 'SRC=" http://www.jb51.net//web/swfobject_source.js "> </script> </head> <Body> <The form id="Form1" > <Div id="flashcontent >" <A href="http://www.adobe.com/go/getflashplayer" > <Img SRC="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" Alt="Get Adobe Flash player" border="0"/> </a> </div> </form> <The script type="text/javascript" >//note that in the Flash file name before I add a var so f=new mit-licensed (" http://www.pec365.com/Flash/f20071113.swf ", "mymovie", "304", "367", "7", "# FFFFFF"); So. Write (" flashcontent "); </script> </body> </html> Suggest you personally perform this piece of code, if you're a novice can see said in a previous Posting introduced the steps to run this code, the real feel &other; Throughout the disaster &; The coming of the. Yes, you will see on the page is blank, it was used to replace cannot display Flash when the backup image was gone, where? I found after debugging, because even if the incoming Flash files address errors, also can create a wrong <Object [… …] > </object> Labels will be <Div id=" Flashcontent" > [… …] </div> In content, which is what you see, will form a high respectively is 304 px wide and 367 px white space (if installed the Flash player, in the left upper corner of the screen click the right mouse button, you will discover something), so so nightmare will come. To deal with the results of this nightmare, as a result, I will think of a bad idea, first of all check according to the incoming Flash files address check whether really exist the file on the server, if the returned result is the Flash file exists, then execute mit-licensed. EmbedSWF () method, and the specific train of thought is to use the XMLHttpRequest object, by way of the GET/HEAD request to the server, and then judge the xmlHttp. Status==200 | | xmlHttp. Status==302 as the basis of file exists, but seems there are still some defects in this way, I have no ability to improve, now will I finally solution sample is as follows:

 


code is as follows:


<Html> <Title> DEMO <Head> <Script language="javascript" type="text/javascript 'SRC=" http://www.jb51.net//web/JavaScript/swfobject.js "> </script> <The script type="text/javascript" > (function() { var xmlHttp, result, flashURL="http://www.pec365.com/Flash/20071113.swf"; var checkFlashURL=function(url) { xmlHttp=GetXmlHttpObject(); xmlHttp.onreadystatechange=function() { if ( xmlHttp.readyState==4 ) { if ( xmlHttp.status==200 || xmlHttp.status==302 ) { return (result=true); } } }; xmlHttp.open("HEAD", url, true); xmlHttp.send(null); }; var GetXmlHttpObject=function() { var xmlHttp=null; try {//Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) {//Internet Explorer try {//Older IE xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {//New IE xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; };//就是用于检查服务器上指定的Flash文件是否存在 checkFlashURL(flashURL); window.onload=function() { if ( result ) { swfobject.embedSWF(flashURL, "flashcontent", "304", "367", "10.0.0", "expressInstall.swf", {}, { quality:"autohigh", wmode:"transparent" }, {}); } else { window.alert("您的Flash地址无效,请仔细检查");//只是用于调试时检查Flash地址地否正确 } }})(); </script> </head> <Body> <The form id="Form1" > <Div id="flashcontent >" <A href="http://www.adobe.com/go/getflashplayer" > <Img SRC="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" Alt="Get Adobe Flash player" border="0"/> </a> </div> </form> </body> </html> Wow, for a few hours in the two words with good, don't be careful to stay company almost 22 points, security guard to catch the person, want to end it, she needed to work again tomorrow to carve the words, ha ha.


This concludes the body part