![]() |
|
|
Published: Wednesday, January 12, 2000 By Brian Rhee Have you ever wondered what the world would be like if there were only one programming language? How about a world where a set of standards were equally supported and backed by every single organization? The "pipe dream" that I described above is just that and unfortunately we have to live in a world that deals with incompatibilities and lack of standardization at every turn. So where am I going with all this? Hold on, I'll explain...
About two years ago I was assigned to a project to help build an application for a client that involved the use of ASP technology. The requirements were gathered and the original spec docs required the use of IE4 by the users of the application. So naturally, the client side scripting language of choice was VBScript and all the testing was done using IE4. Later on as the project grew and the application began to expand in scope, as well as in user base, more and more individuals were crying out that they did not want to give up their Netscape browsers just to use our application. So we were commissioned to convert all the existing HTML and VBScript code to be more cross browser friendly, namely the reformatting of our HTML and also converting the VBScript to JavaScript. Upon finishing the conversion we had tested the application with IE and everything seemed to work perfectly fine, but when testing with Netscape commenced, we had some very disheartening results. To name a few of the problems, functions that worked perfectly well under an IE environment did not even "fire" under Netscape, in addition alignment of text and images were off and sometimes images did not even appear! Not to mention that Netscape does not by itself come with its own debugger and the one that can be downloaded from the Netscape site is a broken link! So the development team and I were left to figure out how and why things worked in IE but not in Netscape. The development team scoured the Internet for any possible information as to why the JavaScript code was not working in Netscape and why the formatting was all screwed up. We found some very useful links (such as developer.netscape.com) as to what properties of JavaScript were supported and which ones were not but not the information that we had been looking for. Namely, the fixes we were looking for had nothing to do with the JavaScript language itself, but how each browser handles specific oddities. Here are a list of some of the quirks we have found with the IE/Netscape compatibility conversion and their explanations.
1. To Do: When centering objects on an HTML page use
2. To Do: Image names cannot have spaces, otherwise the image disappears in Netscape!
3. To Do: Any form element that is created in Netscape must be included within a form, or else Netscape does
not even show the button.
Rather, do it like:
3a. To Do: In addition to including all elements within form tags you must also reference the form
elements by calling them out explicitly such as
4. To Do: When using the
Use this instead
5. To Do: The
6. To Do: All tables must have proper closing tags such as
7. To Do: Use
8. To Do: Use
9. To Do: On forms in IE when finished completing items on a page the 10. To Do: You must create a form object before referencing the item, or else the object will not be able to see the form item.
11. To Do: In IE the 12. To Do: Since we were converting all of our VBScript functions to JavaScript, we were daunted with the task of either rewriting major chunks of code or try to figure out a way to use the existing code we had. Since we maintained proper variable declarations and used lower case variable names and constants we had a much easier time of converting our VBScript functions than we could have had. We first built a JavaScript library that included many of the same common VBScript functions we used such as Trim(), CDbl(), CStr(), IsNumeric(), IsNull(), DateDiff(), etc, and named those functions under the same naming conventions. We then included this library into every page. To see some conversions from VBScript to JavaScript, be sure to check out the VBScript - to - JavaScript Function Translation resource on 4Guys. The next obstacle we encountered was to try and trigger those even driven VBScript functions to now fire under JavaScript event driven functions. The actual solution was elegant but simple, for example take this VBScript code that will work under IE:
To make this work in JavaScript all we had to do was this:
You see the magic here lies in the last part of the script. Referencing the event handler with the implied function causes the desired action. BTW: Keep in mind DO NOT place any of your JavaScript inside tables what-so-ever...This will only lead to problems!
Happy Programming!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||