Page 28 - LoudOffice_Guide-to-HTML_Part-II_Advanced.PDF
P. 28

code, the confirm box returns a boolean with a value of true or false.  This would be used
               within your JavaScript to call another action.


                           < h t m l >
                           < h e a d >
                              < t i t l e > W e l c o m e < / t i t l e >
                           < / h e a d >
                           < s c r i p t >
                           < ! - -  / / H i d e
                           f u n c t i o n  c h k V a l u e ( ) {
                              v a r  c h k T e s t  =  c o n f i r m ( “ I s  9 5  g r e a t e r  t h a n  5 ? ” ) ;
                              i f  ( c h k T e s t  = =  t r u e ) {
                                 a l e r t ( “ T h a t  i s  c o r r e c t . ” ) ;
                              }  e l s e  {
                                 a l e r t ( “ S o r r y ,  y o u ’ r e  w r o n g . ” ) ;
                              }
                           }
                           / / U n h i d e
                           - - >
                           < / s c r i p t >
                           < b o d y  o n L o a d = ”  c h k V a l u e ( ) ” >
                           H e l l o
                           < / b o d y >
                           < / h t m l >
               These three elements can also be used within links, for example, if you were to have a page
               with the following HTML / JavaScript code:
                    < a  h r e f = " # "  o n C l i c k = " a l e r t ( ' D o  i t  a g a i n ! ' ) ; " > C l i c k  o n  m e ! < / a >
               Would output the following:

























               Mouse Over Events
                                    event is one of the most commonly used JavaScript functions on the
               The o n M o u s e O v e r
               Web.  It can be used within many HTML tags, with the most common being the < a >  tag.
               For example, consider the following HTML code that changes the window’s status bar each
               time a link is moused over:


                       <a  h r e f = " h o m e . h t m "  o n M o u s e O v e r = " j a v a s c r i p t :
                       w i n d o w . s t a t u s = ' G o t o  O u r  H o m e  P a g e ' ;  r e t u r n  t r u e "

               LoudOffice.com Guide to HTML – Part II                                               Page 28
   23   24   25   26   27   28   29   30   31   32   33