Information Technology Reference
In-Depth Information
Calling JavaScript
You can “call” JavaScript with or without using behaviors. JavaScript can be
typed directly into the link field on the Properties Inspector. We might call a
JavaScript to perform some sort of function. This topic is not about JavaScript,
nor am I a qualified expert on the subject, but what I am about to explain to you
is pretty simple to understand and very functional to have in your Web page
design arsenal.
When your user opens a pop-up window displaying your work, you want to be
sure that you have an easy and intuitive method for the user to close the window
and return to the home page. You can rely on user to click on the window's title
bar and close the window by clicking the X. But, it's kind of nice give the user
a close button somewhere in your pop-up window page designs. This is where
some simple JavaScript comes in.
Make a Close Button
In a pop-up window (don't put this on your home page — it will close it!) make
a new layer and type the words close window and apply a style (or make a new
one for closeout). Highlight the text and in the Properties Inspector go to the
link field and type: JavaScript:self.close(). Now preview the Web page in
a browser by pressing the F12 key and Close the window. You must
preview the page in the browser to execute the JavaScript and see it run.
Congratulations, you have successfully written JavaScript. You can explore
some more on your own; for now this little JavaScript morsel will help you make
your pop-up windows a whole lot more user friendly.
To use Behaviors to call JavaScripts in Dreamweaver, type close again in the
layer you made before. Highlight the text that will trigger the JavaScript (in our
case, the close again button), now click on the + in the Behaviors palette and
choose Call JavaScript . Set the event to onClick. In the dialog box type
self.close() and press F12 to preview in the browser. Thus, the same result as
when we typed it into the Link field on the Properties Inspector.
You use the close button with forward and back buttons in your pop-up
windows to provide user navigation. This navigation system should be very
discreet and should not interfere with portfolio work in any way. The navigation
should be in the same location on every page.
Search WWH ::




Custom Search