Page 136 - DCAP202_Fundamentals of Web Programming
P. 136

Unit 10: Browser Objects




          The following JavaScript code may be used to identify the source of the URL.          Notes
          switch  (window.location.protocol)
          {
          case  “http:”:
          document.write(“From  Web<BR>\n”)
          break
          case  “file:”:
          document.write(“From  Local  computer<BR>\n”)
          break
          default:
          document.write(“Unknown  Source<BR>\n”)
          break
          }
              search - The URL query string section. This is the section after and including the question
               mark.

              target - The URL link’s target name.



              Task  Analyse the use of Location objects.

          10.4.2 Location Objects – Methods

          The following method are used in location objects:

              reload() - The current window document is reloaded. If a value of true is passed to the
               reload function, the reload is forced to do an HTTP GET of the document.




             Notes  This is not normally done but is useful when you think the server contents may be
             different from your cache.
              replace(URL) - Requires a URL as a parameter. It loads the document at the URL on top of
               the current document.



             Did u know?  A new entry is not placed in the history object.
          Self Assessment

          Fill in the blanks:

          10.  The JavaScript ........................... is a property of the window object.
          11.  ........................... 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.
          12.  ........................... property specifies the URL hostname and port.










                                           LOVELY PROFESSIONAL UNIVERSITY                                   129
   131   132   133   134   135   136   137   138   139   140   141