September 29, 1998

JavaScript On or Off?

When using JavaScript in your Web pages, you should keep in mind that a user’s browser might not support JavaScript. This could either be because the browser is old or because the user disabled JavaScript. Either way, the tag provides a solution. Any HTML enclosed between and will only be

Cursors Ready

Using JavaScript, you can set up a form such that when the Web page is loaded the cursor is in the text box. This functionality avoids making the user click into the box–instead the user can just type. Through JavaScript and the Document Object Model, you can easily access the

Namespace std May Not Be Modified

Generally, namespaces are open so it is perfectly legal to expand existing namespaces with additional declarations and definitions in several files. The only exception to the rule is namespace std. According to the C++ Standard, the result of modifying namespace std with additional declarations–let alone a removal of existing ones–is

Using JavaScript to Check if Frameset is Loaded

You can use JavaScript at the top of an HTML document to detect if a frameset is loaded and if not, load the frameset. If a window’s top property points to the window itself then that frame is the main frameset or document: This is document #1 If that’s true

JavaScript Debugger or Development Environment

If you’re looking for a development environment for JavaScript, JavaScript debuggers are available as a free download from both Microsoft and Netscape. The feature set of the two products is similar, although Microsoft’s debugger will also allow you to step through scripting done in other languages, such as VBScript. I

Default Arguments in Virtual Functions Must be Identical

You should pay attention when using default arguments in virtual functions. The default values in the overriding function have to be identical to the corresponding default values in the base class. Otherwise, unexpected results may occur: class Base {public: virtual void say (int n = 0) const { cout

Include Guards

#including a file more than once during the same compilation session will most likely cause the compiler to issue error messages since definitions and declarations of the file are repeated. However, in many cases, the same file may be #included in different source file that are compiled together: #include “Time.h”

Seed the Random Number Generator

You can use Rnd followed by Randomize to seed Visual Basic’s random number generator. Whenever you use the same seed, Rnd produces the same sequence of random numbers: Rnd -1Randomize seed

Better Auto-Propercase

The “Auto-Propercase Text Box at Entry” tip [VBPJ May 1997, page 63] has a simpler solution. The StrConv function can propercase any string. You can achieve the same effect with this code in the KeyUp event of a text box: Private Sub Text1_KeyUp(KeyCode As Integer, _ Shift As Integer) Dim

No more posts to show