the Chinese customs, not after the 15th day or on New Year's day, here to give your friends thanks to the garden an old age. Coincides with the company's web site home page need to redesign these days, at the end of last year the company &other Personnel streamlining &throughout; Later, a man have to do more than one person live, suddenly found out that the burden is heavy. It's not, this thing is not my work scope, unfortunately, also let me participate, unfortunately the blessing of the BOSS to my task, just I have been keen on the front end of the development tasks. Before have been engaged in company website background management program development, more is to deal with business logic on the server side, there has been no opportunity, in the front of the I love enduring develop. Practice is the best way for testing truth, through solving the practical tasks assigned to me is a rare big test, learn the knowledge of many scattered through books and all kinds of information, but didn't get the opportunity to mix them together to time &other; Comprehensive test &throughout; , ha ha. Ink in front of so many, have to is suppressed for a long time, ha ha. Let me first describe the mission requirements, the company's web site home page is made up of five balls JPG photo, its action is used for navigation, click on the words on each ball after secondary pages will open the corresponding information, accordingly with the image of a nearly identical version of Flash. And boss decorate give one of my tasks is: when the client browser to install the Flash file player, Flash version of navigation, navigation and vice display JPG images. To get the task, consider for a moment, is both the front-end development, browser compatible to consider of course, browser across the gap between the best way is to use one or more mature JavaScript framework, luckily just has a very mature and exquisite JS framework, called: mit-licensed. JS. First contact mit-licensed. Js is its V1.5, but this time, I solve the problem using the V2.1, there're some differences on the use between the two. Give my feeling is on whole V2.1 than V1.5, was a great leap forward, V2.1 regardless of from the framework source code or use process, more in line with the object-oriented JavaScript programming style. Shortly I will explore in a JavaScript study perspective, to experience together with you on this &other; STH over and over again throughout the &; Trip, whether you are a novice like me, or have been able to skillfully write all kinds of veteran of JS code, hope please punches, hope everyone to civilization mentality pointed out the mistakes in my myopia in thinking and writing. The code below is my from mit-licensed V1.5 a documentation (such as want to further understand please click this link to go V1.5) adapted to the use of examples:

 


code is as follows:


<Html> <Title> DEMO <Head> <Script type="text/javascript 'SRC=" http://www.jb51.net//web/swfobject_source.js "> </script> <The script type="text/javascript" > Var so=new mit-licensed (" http://www.pec365.com/Flash/20071113.swf ", "mymovie", "304", "367", "7", "# FFFFFF"); So. Write (" flashcontent "); </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> If you want to know the mit-licensed briefly the meaning of each parameter in (), please refer to the documentation, this is not repeated again. I strongly suggest you, &other V1.5 using the sample &throughout; Code in copying to notepad, and click mit-licensed V1.5 V1.5 framework of the source files needed to download, unzip found swfobject_source. Js (uncompressed version, the compressed version of the file name is mit-licensed. Js) file, the notepad file renamed demo. With swfobject_source. After HTML, js files can be placed in the same folder, then please in IE6/IE7, fox, opera, safari, the navigator browser, chrome, etc. Any run and see the result. If you follow my advice, operation should be shown on the page is this picture , rather than a Flash file, is this why? If your PC to install the IE series, follow these steps: click the Internet explorer icon, on the find toolbar &other; Tools &throughout; The menu, the selected &other; Internet options &throughout; In the open window click &other; Senior &throughout; To find &other Disable script debugging (Internet Explorer) &throughout; Its check box in front of the option, be removed, click &other; Identify &throughout; . Please after do this, again to browse the demo. The HTML page, will find pop up a error message box, it prompt error message is as follows: &other; A runtime error, whether to need to debug. Line: 117 error: object 'null' is empty or not. Throughout the &; If you are using right VS 2003/2005/2008 series of IDE to do development, so I think don't need to teach you how to debug JavaScript code, you can var so=… … Above to play a debugger, and then debug tracking, after constantly press F11 until through. So the write () method to track swfobject_source. Js files inside, you will find that is passed to the so. Write (elementId) argument " Flashcontent" In the document. The getElementById (" flashcontent") Value is null, this again is why? Find out the problem? Ha ha, if you still don't know much about the a to the JavaScript novice, you will like I suddenly lost, after after many debugging and modification of the code, I believe my JS code itself is written there is no wrong, is the external load swfobject_source. JS file has a problem, if there is a problem, the problem is out in where? At that time, I sought a solution to the problem of the error so I amend the above code to the following example:

 


code is as follows:


<Html> <Title> DEMO <Head> <The script type="text/javascript" >//perform an anonymous function, there is a difference and perform a common function (function () {var flash=document. The getElementById (" flashcontent "); The var MSG=null; window. The onload=function () {if (flash) {MSG='The element does exist.'; flash. The innerHTML=MSG} else {MSG='The element does not exist'; window. The alert (MSG);}};}) (); </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" _fcksavedurl="" http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" Alt="" Get Adobe Flash player" border="0"/> </a> </div> </form> </body> </html> If you execute the above code will find, still found that show on the page or the picture , and pop up a contain &other; The element does not exist" The alert box, it seems the problem is not from the external load swfobject_source. Js file. If you see here, will experience my chagrin, then after a little rest, wake up the brain look back, only to find the essence of the problem in &other; The HTML DOM throughout loading &; On. In a page in the page header (namely ) between the JS script and JS files will be loaded from an external file before the HTML DOM really structure is carried out. So this two place to execute the script and can not access the DOM did not exist. You should know the real reason, that is, the sample in 1.1 JS code execution process, visited before also structure <Div id=" Flashcontent" > … … </div> . Ok, see here, there is one last step need you hands-on operation, is simple a change on the above code, take an elegant way to solve about &other; The HTML DOM throughout loading &; Question, what method is it, I think we should probably guess, yes, it is following this way:

 


code is as follows:


<Html> <Title> DEMO <Head> <Script type="text/javascript 'SRC=" http://www.jb51.net//web/swfobject_source.js "> </script> "_fcksavedurl=" "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" > Var so=new mit-licensed (" http://www.pec365.com/Flash/20071113.swf ", "mymovie", "304", "367", "7", "# FFFFFF"); So. Write (" flashcontent "); </script> </body> </html> Running in front of thousands of words, just how many detours in the description I'm gone, met in the process of solving the problem that trouble, free from trouble using the study of knowledge, and learn the knowledge, although a bit redundant, but if you like I also have a different harvest?

# 0 - #


This concludes the body part