★ wanayoo — archive 1999 http://developer.netscape.com/docs/presentations/codestock/javascript/codesto1.htmlNouvelle recherche | Portail wanayoo

CODESTOCK ON JAVASCRIPT 1.2 ENHANCEMENTS

As part of its continuing developer outreach efforts, Netscape holds informal events at the Mountain View headquarters called "CodeStocks" in which developers gather to hear a presentation on the latest Netscape technology followed by a question and answer session on the topic with development engineers. To make the same information accessible to a wider audience, Netscape is making the transcript of the most recent session available on DevEdge Online. This document is the transcript for the CodeStock held on March 20, 1997 on the topic "JavaScript 1.2 Enhancements in Netscape Communicator."

AGENDA 

CORE JAVASCRIPT ENHANCEMENTS  

The core JavaScript language has numerous enhancements in Preview Release 2 of Netscape Communicator. These include labeled statements, break and continue, the switch statement, do-while loops, and enhanced equality comparison with additional typechecking. The setInterval statement makes it easy to set repeating timouts, and both setInterval (for repeating timeouts) and setTimeout (for one-time timeouts) can accept a function name and arguments directly without the need to place the function call within a string. There is also an enhanced event model with an event object that specifies the kind of event and the X and Y coordinates at which it took place. These new features have already been documented online in the document What's New in JavaScript 1.2 for Navigator 4.0

LAYERS 

The LAYER tag has been supported since Preview Release 1 of Netscape Communicator, and its syntax is documented online in the Dynamic Layers Documentation. To see some demonstrations of the kinds of compelling pages this new feature makes possible, download the most recent Preview Release of Netscape Communicator and check out this page of Customer Layers Demos

Preview Release 3 of Netscape Communicator will bring many additional enhancements to the layer tag. The complete list of enhancements has not been finalized as of this writing, and there can be no guarantees regarding the functionality of Preview Release software, but planned enhancements include the following: 

In Preview Release 2, Netscape Communicator already has partial support for the recently-released draft proposal by the World Wide Web Consortium for Positioning Elements with Cascading Style Sheets, including the position, left, top, and z-index properties. Preview Release 3 of Netscape Communicator should feature almost full compliance with the latest draft proposal. In using these features, keep in mind that the proposal itself has not yet been finalized into a standard by the World Wide Web Consortium and is still subject to change.


QUESTION AND ANSWER SESSION ON LAYERS  


WINDOW CONTROL METHODS

Preview Release 2 of Netscape Communicator has added several new methods for controlling the size, position, and scrolling of windows, including moveTo, moveBy, scrollTo, scrollBy, resizeTo, and resizeBy. It is also possible to specify a windows size within a call to window.open. These new features have already been documented online in the document What's New in JavaScript 1.2 for Navigator 4.0

Preview Release 3 of Netscape Communicator will add support for the following methods:

CANVAS MODE

Preview Release 2 of Netscape Communicator has added support for "canvas mode" display which displays a page using the full screen with no surrounding window elements or "chrome." Documentation for the use of canvas mode in PR2 and a demo are available online at the Netscape Communicator What's Hot Page. For security reasons, to use canvas mode in PR2, the user must start Netscape Communicator with a special command line switch. This switch will be available for PR2 only. From Preview Release 3, the use of canvas mode will be restricted to signed scripts to ensure that applets can't seize control of the full screen without the user's permission.

STYLE SHEETS

Netscape Communicator is adding support for the control of HTML page layout and format using style sheets. Netscape will support both Cascading Style Sheets, which have been recommended by the World Wide Web Consortium as a standard for the static definition of formatting information, and Dynamic Style Sheets, which make the power of Cascading Style Sheets accessible from JavaScript scripts using a simple, intuitive syntax.

Style sheets enable the HTML author to specify the following kinds of properties for elements, blocks, or classes of elements:

Style sheets are useful because they:

Full details about the syntax and functionality of style sheets are available in the online documentation for Dynamic Style Sheets and in the World Wide Web Consortium's Recommendation for Cascading Style Sheets, level 1.


REGULAR EXPRESSIONS 

Preview Release 3 of Netscape Communicator will add support for the use of regular expressions in JavaScript. Regular expressions in JavaScript 1.2 will be like regular expressions in Perl. They will provide the same basic functionality as regular expressions in Perl, and it will be easy for experienced Perl developers to learn to use regular expressions in JavaScript. To reduce the learning curve for developers without Perl experience, JavaScript regular expressions will provide a functional syntax which is simpler than that of Perl. 

Regular expressions in JavaScript 1.2 will support a parenthetical syntax for matching sub-expressions. It will also be possible to do replacement on matched sub-expressions in the same way this is possible in Perl using $1, $2, and so on. 

QUESTION AND ANSWER SESSION ON REGULAR EXPRESSIONS  

SIGNED JAVASCRIPT  

Preview Release 3 of Netscape Communicator will add the ability to sign scripts with a digital signature and a capabilities based security model that will give the user flexible control over what resources a script is granted access to.

Today, the JavaScript security “sandbox" protects the user's system by preventing unsigned scripts from accessing local resources. This sandbox prevents JavaScript scripts from causing the kind of security breaches which have gained so much attention in recent months for certain other Internet development technologies. 

Signed JavaScript is needed because in order to provide additional power and functionality, scripts need to be able to get out of the sandbox and access local resources with the user's permission. Users need to be able to specify which scripts they will trust and grant this access to. Users already do the same thing when they purchase shrink-wrapped software, install it on their machine, and give it access to their local resources. 

At the outset, we should define some key terms: 

HTML files are being enhanced to support signing. The ARCHIVE attribute lets scripts refer to JAR files, and the ID attribute associates a script with a signature. 

Here are some code samples using these new attributes: 

<SCRIPT ARCHIVE=foo.jar ID=1> 
// your script here... 
</SCRIPT> 

<INPUT TYPE=BUTTON ID=2 
 onClick=“/* your handler */”> 

Scripts will be able to request privileges to determine what resources they have access to. They will do this by calling Java classes to gain access to targets. Here is some sample code showing how that can be done: 

var targ = netscape.security.Target. findTarget("UniversalBrowserRead"); 
var mgr = netscape.security.AppletSecurity. getPrivilegeManager(); 
mgr.enablePrivilege(targ); 

A few of the targets that scripts can request access to: 

Java defines additional targets besides those listed above. 

A tool will be provided to sign scripts. All scripts on a page must be signed for any script to request privileges; this avoids security holes that would be created by having signed and unsigned scripts coexisting on the same page. It's not possible to sign javascript: URLs. 

It's important to be aware that moving HTML files from platform to platform on the server side may require that the scripts be resigned due to platform-specific differences in how the files are encoded. Windows, Mac, and UNIX platforms all represent text differently. For example, if an HTML file is moved from a UNIX server to a Windows server by FTP as an ASCII text file, the file will be mapped from one format to the other, the characters within it will be changed, and the digital signature will be invalidated because the file's binary image has changed. Resigning the script will solve the problem; moving the file between platforms in binary transfer mode will avoid it. 

In summary, scripts can be signed to show who produced them. Signed scripts may request privileges through Java, and scripts with privileges may access normally restricted information. This feature will dramatically increase the power of JavaScript scripts while preserving the security that users demand for Internet and intranet application deployment. 

QUESTION AND ANSWER SESSION ON SIGNED SCRIPTS 



For the latest technical information on Sun-Netscape Alliance products, go to: http://developer.iplanet.com

For more Internet development resources, try Netscape TechSearch.


Copyright © 1999 Netscape Communications Corporation.
This site powered by: Netscape Enterprise Server and Netscape Compass Server.