Archive for December, 2007

Bulletproof web design - 276 Part III . Document Objects Reference While

Monday, December 31st, 2007

276 Part III . Document Objects Reference While there is no known workaround for resurrecting modified content, your script can at least know if the page is being loaded into one of these hidden win dows: The NN-specific window.outerHeightand window.outerWidth properties are zero. If you don t want an immediate script statement to run before being printed, use an ifconstruction to let the nested statement(s) run only if either of those dimension properties is greater than zero. Printing in IE4 While the window.print() method is not available in IE4, it is possible to script printing in the Win32 OS platforms via the built-in browser object. To use this ActiveX object, you must first include the following HTML somewhere in your document (at the end of the BODY is fine): The long CLASSIDattribute must be copied exactly. This HTML adds an object to the document object model that can be scripted. The object has several commands available, one of which provides printing services. The commands are numbered, and the one for printing is the following: IEControl.ExecWB(6, 1) If the user cancels the Print dialog box, a script error may appear, so be sure to trap for errors (see the window.onerrorproperty earlier in this chapter). If you change the second parameter to 2, the Print dialog box does not appear, but that isn t a very user-friendly way to treat printing. Related Items: window.back(), window.forward(), window.home(), window.find() methods. prompt( message , defaultReply ) Returns: String of text entered by user or null. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . The third kind of dialog box that JavaScript can display includes a message from the script author, a field for user entry, and two buttons (OK and Cancel, or Yes and No on Mac versions of Navigator 2 and 3). The script writer can supply a prewritten answer so that a user confronted with a prompt dialog box can click OK (or press Enter) to accept that answer without further typing. Supplying both parameters to the window.prompt()method is important. Even if you don t want to supply a default answer, enter an empty string as the second parameter: prompt( What is your postal code? , ) If you omit the second parameter, JavaScript inserts the string undefined into the dialog box s field. This string is disconcerting to most Web page visitors. windowObject.prompt()
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

275Chapter 16 .Window (How to cite a web site) and Frame Objects print() Returns:

Sunday, December 30th, 2007

275Chapter 16 .Window and Frame Objects print() Returns: Nothing. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . The print() method provides a scripted way of sending the window or a frame from a frameset to the printer. In all cases, the Print dialog box appears for the user to make the typical printer choices when printing manually. This prevents a rogue print() command from tying up a printer without the user s permission. The precise behavior of the print()method varies a bit with the different ways NN and IE (not to mention operating systems) handle printing. In NN4+ (except for the Windows OS), you can print all frames of a frameset in one print()command when it is invoked for the framesetting (parent) document. NN4 for Windows, however, does not print the entire frameset at once. You can write a script that iterates through all frames and prints them with delays to let the content be sent to the print spooler: function printFrames(n) { parent.frames[n++].print() if (n < parent.frames.length) { setTimeout( printFrames( + n + ) ,5000) } } Invoke this function as printFrames(0), and the function does the rest. In IE5, the print dialog box gives the user the choice of printing just one frame or all of the frames. Make sure that the print()method is invoked for the desired frame when you want only that frame to print. The browser defaults to printing just that frame. IE5 introduces some print-specific event handlers that are triggered by scripted printing as well as manual printing. The events begin to fire after the user has accepted the Print dialog box. An onBeforePrint event handler can be used to show content that might be hidden from view but should appear in the printout. After the content has been sent to the print spooler, the onAfterPrint event can restore the page. On the CD-ROM Example (with Listings 16-27 and 16-28) on the CD-ROM NN4 printing anomalies The Windows and Unix versions of NN4 handle printing in a way that can cause the page to not print what the user sees because before the page prints, it is loaded into a hidden window. Any immediate scripts in the page run again, but any user- induced, scripted content modifications will most likely not be a part of the page. windowObject.print()
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Web hosting plans - 274 Part III . Document Objects Reference Internet

Sunday, December 30th, 2007

274 Part III . Document Objects Reference Internet Explorer idiosyncracies Creating subwindows in IE can be complicated at times by undesirable behavior by the browser. One of the most common problems occurs when you attempt to use document.write()to put content into a newly created window. IE, including some of the latest versions, fails to complete the window opening job before the script statement that uses document.write() executes. This causes a script error because the reference to the subwindow is not yet valid. To work around this, you should put the HTML assembly and document.write() statements in a separate function that gets invoked via a setTimeout()method after the window is created. You can see an example of this in Listing 16-26. Another problem that affects IE is the occasional security violation ( access denied ) warning when a script attempts to access a subwindow. This problem goes away when the page that includes the script for opening and accessing the subwindow is served from an http server, rather than accessed from a local hard disk. Finally, an all-too common bug in Windows 95/98 allows the Registry to become mildly corrupted in some key areas that IE needs for opening and referencing new windows. The most common symptom of the problem is a script error on the statement that invokes window.open(), but other indications include error messages that the document.write() method is not supported in the subwindow or that the RPC server is not available. The problem cannot be fixed by JavaScript but requires human intervention on the affected PC. Here are the steps to repair the problem: 1. Click Start and then click Run. 2. In the Open box, type the following line: regsvr32 actxprxy.dll 3. Click OK and then click OK again after you receive the following message: DllRegisterServer in actxprxy.dll succeeded. 4. Click Start and then click Run. 5. In the Open box, type the following line: regsvr32 shdocvw.dll 6. Click OK and then click OK again after you receive the following message: DllRegisterServer in shdocvw.dll succeeded. 7. Shut down and restart your computer. The corruption is reported to be caused by application installers and uninstallers that don t clean up after themselves the way they should. The fact that this problem is rather common in IE4 under both Windows 95 and 98 might make you gun-shy about utilizing multiple windows in your application. On the CD-ROM Example (with Listing 16-26) on the CD-ROM Related Items: window.close(), window.blur(), window.focus() methods; window.closed property. windowObject.open()
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Web design - 273Chapter 16 .Window and Frame Objects A Navigator

Saturday, December 29th, 2007

273Chapter 16 .Window and Frame Objects A Navigator 2 Bug Workaround If you re concerned about backward compatibility with Navigator 2, you should be aware of a bug in the Macintosh and UNIX flavors of the browser. In those versions, if you include a URL as a parameter to window.open(), Navigator opens the window but does not load the URL. A second call to the window.open() method is required. Moreover, the second parameter must be an empty string if you add any third-parameter settings. Here is a sample listing you can adapt for your own usage: New Window

This workaround can also be used without penalty in Windows versions of Navigator. When scripts in the subwindow need to communicate with objects and scripts in the originating window, you must make sure that the subwindow has an opener property if the level of JavaScript in the visitor s browser doesn t automatically supply one. See the discussion about the window.openerproperty earlier in this chapter. Invoking multiple window.open()methods with the same window name parameter (the second parameter) does not create additional copies of that window in Netscape browsers (although it does in Internet Explorer). JavaScript prevents you from creating two windows with the same name. Also be aware that a window.open()method does not bring an existing window of that name to the front of the window layers: Use window.focus()for that. windowObject.open()
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

272 Part III . Document Objects Reference (Free web hosting with ftp) Specifying

Saturday, December 29th, 2007

272 Part III . Document Objects Reference Specifying a window name Getting back to the other parameters of window.open(), the second parameter is the name for the new window. Don t confuse this parameter with the document s title, which would normally be set by whatever HTML text determines the content of the window. A window name must be the same style of one-word identifier that you use for other object names and variables. This name is also an entirely different entity than the windowobject that the open()method returns. You don t use the name in your scripts. At most, the name can be used for TARGETattributes of links and forms. Loading content into a new window A script generally populates a window with one of two kinds of information: . An existing HTML document whose URL is known beforehand . An HTML page created on the fly To create a new window that displays an existing HTML document, supply the URL as the first parameter of the window.open()method. If your page is having difficulty loading a URL into a new page (except as noted in the sidebar A Navigator 2 Bug Workaround ), try specifying the complete URL of the target document (instead of just the filename). Leaving the first parameter as an empty string forces the window to open with a blank document, ready to have HTML written to it by your script (or loaded separately by another statement that sets that window s location to a specific URL). If you plan to write the content of the window on the fly, assemble your HTML content as one long string value and then use the document.write()method to post that content to the new window. If you plan to append no further writing to the page, also include a document.close() method at the end to tell the browser that you re finished with the layout (so that the Layout:Complete or Donemessage appears in the statusbar, if your new window has one). A call to the window.open()method returns a reference to the new window s object if the window opens successfully. This value is vitally important if your script needs to address elements of that new window (such as when writing to its document). To allow other functions in your script to reference the subwindow, you should assign the result of a window.open() method to a global variable. Before writing to the new window the first time, test the variable to make sure that it is not a null value the window may have failed to open because of low memory, for instance. If everything is okay, you can use that variable as the beginning of a reference to any property or object within the new window. For example: var newWindow … function createNewWindow() { newWindow = window.open( , ) if (newWindow != null) { newWindow.document.write( Hi! ) } } That global variable reference continues to be available for another function that perhaps closes the subwindow (via the close() method). windowObject.open()
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

271Chapter 16 .Window and Frame Objects netscape.security.PrivilegeManager.revertPrivilege( UniversalBrowserWrite ) } (Web hosting rating)

Friday, December 28th, 2007

271Chapter 16 .Window and Frame Objects netscape.security.PrivilegeManager.revertPrivilege( UniversalBrowserWrite ) } }

Select new window options:
All Browsers Features:
toolbar location
directories status
menubar scrollbars
resizable copyhistory
Communicator Features:
alwaysLowered alwaysRaised
dependent hotkeys
titlebar z-lock

windowObject.open()
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

270 Part III (Web site construction) . Document Objects Reference To

Friday, December 28th, 2007

270 Part III . Document Objects Reference To apply signed scripts to opening a new window with the secure window features, you must enable UniversalBrowserWriteprivileges as you do for other signed scripts (see Chapter 46). A code fragment that generates an alwaysRaised style window follows: You can experiment with the look and behavior of new windows with any combination of attributes with the help of the script in Listing 16-25. This page presents a table of all NN-specific new window Boolean attributes and creates a new 300 300 pixel window based on your choices. This page assumes that if you are using NN4, you have codebase principals turned on for signed scripts (see Chapter 46). Be careful with turning off the title bar and hotkeys. With the title bar off, the content appears to float in space, because absolutely no borders are displayed. With hotkeys still turned on, you can use Ctrl+W to close this borderless window (except on the Mac, for which the hotkeys are always disabled with the title bar off). This is how you can turn a computer into a kiosk by sizing a window to the screen s dimensions and setting the window options to titlebar=no,hotkeys=no, alwaysRaised=yes . Listing 16-25: New Window Laboratory window.open() Options