JavaScript
  Home arrow JavaScript arrow Page 6 - The DOM Location Object Properties
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

The DOM Location Object Properties
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-12-01

    Table of Contents:
  • The DOM Location Object Properties
  • Hash It Up
  • Being a Good Host
  • Using Href
  • Getting the Pathname
  • Following Protocol

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The DOM Location Object Properties - Following Protocol


    (Page 6 of 6 )

    The protocol object returns or sets which protocol the present URL is using. An example of a protocol would be HTTP or FTP. Here we will say that our URL is http://www.devshed.com/. Here is the code:


    <html>

    <body>

    <script type="text/javascript">

    alert(location.protocol);

    </script>

    </body>

    </html>

    This will result in an alert box containing the following text:

      http:

    And just as with the others, we can create the result in a window instead of a pop-up, like so:


    <html>

    <body>

    <script type="text/javascript">

    document.write("This URL uses the following protocol: ");

    document.write(location.protocol);

    </script>

    </body>

    </html>

    Giving us:

      This URL uses the following protocol: http:

    Search Me

    You have probably seen URLs that seem to be asking a lot of questions on the web. We can extract the data after the question mark (?) using the search object. For instance, if you wanted to retrieve stock data about Microsoft off of Yahoo Finance, this is the URL you would be directed to: http://finance.yahoo.com/q?s=msft. Let's assume that we are going to use search on this URL. Here is the program:


    <html>

    <body>

    <script type="text/javascript">

    alert(location.search);

    </script>

    </body>

    </html>

    This would create a pop-up with the following data in it:

      ?s=msft

    Conclusion

    Well that gives us a basic overview of all the Location Object Properties. In our next article we will cover the three Location Object Methods. There are only three, and so as a bonus we will also begin a discussion of the History Objects as well. The History Objects let us work with the user's history data, giving us the ability to allow them to move back and forth among recently-visited URLs. It's a simple yet powerful tool, so make sure you check back in frequently. Thanks for reading.

    Till then...


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek