Page 135 - DCAP202_Fundamentals of Web Programming
P. 135

Fundamentals of Web Programming




                    Notes             next - The URL of the next document in the history object.
                                      previous - The URL of the last document in the history object.
                                   10.3.2 History Objects – Methods


                                   The Methods of JavaScript history objects are as follows:
                                      back() - Go to the previous URL entry in the history list. This does the same thing as the
                                       browser back button.

                                      forward() - Go to the next URL entry in the history list. This does the same thing as the
                                       browser forward button. This  is only effective when  there is  a next document in the
                                       history list. The back function or browser back button must have previously been used for
                                       this function to work.
                                      go(relPos | string) - This function will accept an integer or a string. If an integer is used, the
                                       browser will go forward or back (if the value is negative) the number of specified pages in
                                       the history object (if the requested entry exists in the history object).

                                   Self Assessment

                                   Fill in the blanks:
                                   7.  The JavaScript ........................... is property of the window object.
                                   8.  ........................... function will accept an integer or a string.
                                   9.  The ........................... property specifies the number of entries in the history object.

                                   10.4 Location Objects

                                   The JavaScript location object is a property of the window object. It can be used to control the
                                   web page displayed by the browser.
                                   10.4.1 Location Objects – Properties


                                   JavaScript location object has the follwing properties:
                                      hash - The URL anchor part including the leading hash mark if one exists This is the part of
                                       the URL that is used to point to point to a particular part of a page where a named anchor is.




                                     Notes  The hash is the part containing the # sign that points to the particular page location.

                                      host - The URL hostname and port. The URL http://abc.com/index.html has the host
                                       value of ctdp.tripod.com:80. The colon and port is only included when specified. The URL
                                       http://ctdp.abc.com/index.html has the host value of ctdp.tripod.com.
                                      hostname - The URL hostname section
                                      href - The entire URL. The following code will load the home CTDP page: location.href =
                                       “http://ctdp.tripod.com/” The following code will display the URL of the current page:
                                       document.write(location.href)
                                      pathname - The URL pathname section
                                      port - The URL port section.

                                      protocol - The URL protocol section including  the colon  after the protocol name. The
                                       values are normally http: or file:.

          128                               LOVELY PROFESSIONAL UNIVERSITY
   130   131   132   133   134   135   136   137   138   139   140