Editing an existing JavaScript
You can use the JavaScript Editor to edit existing JavaScripts.
To edit an existing JavaScript: - To open the JavaScript Editor, do one of the following:
- Double-click the JavaScript icon
in the document window. - Select the JavaScript icon
in the document window, and then click the Edit button in the Inspector.
- If the icons on the toolbar in the JavaScript Editor are inactive, choose a script name from the list at the left side of the JavaScript Editor.
Create event definitions by entering event codes in the Event Code text box. - Choose an option from the View menu, then drag an object from the Object list in the Script Inspector to the JavaScript Editor window. For example, choose Events from the View menu to display a list of JavaScript events that you can insert in your JavaScript.
- In the Script Inspector, enter event code in the Event Code text box to create event definitions.
Choose a function declaration from the Function pop-up menu in the JavaScript Editor toolbar to navigate directly to that location in the script. (See Navigating through code.)
- Close the JavaScript Editor to save your work.
- Do one of the following to open your Web page in the browser you selected for previewing and testing in the Preferences dialog box:
- Choose File > Preview In > Default Browser.
- Click the Show in Browser button
on the toolbar.
Note: In Mac OS, you cannot preview the effects of a JavaScript. The following sample JavaScript code shows how to use a simple JavaScript to display the time and date obtained from the viewer's operating system. JavaScript sample code and result - The document.write() method on the "Your Local Time" line writes an H1-formatted text string from the document to the screen of the browser.
- The new Date() method creates a new date object containing the long version of the current date from the viewer's operating system. This object is assigned to currtime.
- The last line is output to the browser's screen using a document.write() method, with the embedded currtime variable set to the current time and date.
|