Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Frequently sought solutions

Our esteemed columnist tackles your most common JavaScript questions

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 2 of 6

This bug was quickly recognized, and since Netscape 2.01 this feature has been disabled or restricted. In Netscape 2.01 and 2.02, JavaScript ignores the combination of submit() and mailto:. In Netscape 3.0, it is now possible to work around this restriction using the click() method. However, it's important to remember that the default setting of Netscape warns users that their e-mail names are about to be sent. They can choose to cancel the submission.

How do I prevent others from viewing my JavaScript code?
Programmers are justifiably nervous about spending days, weeks, or even months on a project, only to have the code for it openly available and therefore "free for the taking" by anyone. JavaScript is both an interpreted language and a client-based language, which means that the code for a JavaScript program is readily viewable by anyone who knows how to use the View Source command, or save a page to a local disk file.

Since there is no way to prevent others from viewing (and possibly stealing) your work, you have two alternatives:

  • Forget about it, and get on with the next project.
  • Rewrite the code using Java, or a server-side program.


How do I make sure my program works on every version of Navigator and Internet Explorer?
This question is placed in the "what JavaScript cannot do" section because writing universal JavaScript code -- at least code of any complexity -- is not possible, even for Netscape.

The JavaScript language specification has been too fluid to assure compatibility across versions. Bugs, quirks, and glitches exist from version to version, making it extremely difficult to ensure that pages work reliably for everyone. As an example, certain aspects of using the document.write() method with frames were "broken" in Netscape 2.01 for some platforms. The problem was fixed for users of 2.02 and 3.0, but there are still copies of 2.01 in use.

Compounding the problem, JavaScript can behave differently from platform to platform. This is to be expected to some degree, but the problem ranges from mere annoyances to downright hair-pulling grief. As an example, in Netscape 2.0x the document.title property cannot be read when using a Unix version of Netscape. In other versions the property returns the title of the document as it should.

If you must make your pages 100% compatible with all versions of Netscape Navigator 2.0x and 3.0, and possibly even with Internet Explorer 3.0 as well, you're best off limiting the JavaScript code you use. More elaborate scripts, such as those that interact with other windows or frames, are more prone to give you compatibility problems.

How do I use the new JavaScript 1.1 commands in Internet Explorer 3.0?
Easy answer: you don't. JavaScript 1.1 (the new version of JavaScript as used in Navigator 3.0) offers functionality that Internet Explorer 3.0 does not yet currently support.

The 10 most common solutions JavaScript programmers ask for

Here are ten of the most commonly asked-for solutions by those working with JavaScript. Where appropriate, a short example is provided for each problem/solution.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources