1. Home
  2. Computing & Technology
  3. JavaScript

Current Page Reference

2. Sample

Join the Discussion

Questions? Comments?

Let's take a look at what the address of this page is and also at what fields we might want to reference separately within that address.

The six fields described in bold have been extracted from the address of this page and made available to be separately referenced by any Javascript sode on this page (such as the script that displays the above details. In most cases you will be able to test which page you are on using uri.page which contains the page name extracted from the address but in some cases you may want to test uri.file which contains the entire filename instead. If you have multiple folders/directories within your site you may also need to test uri.path and if you have mirrored copies of your site and need to test which one you are on you may want to check uri.dom.

If you like the idea of being able to reference the parts of the page address like this instead of having to extract the piece you want each time you need to reference it then you will want to obtain the script.

Introduction | Sample Page | Obtain the Script | Add to Your Scripts
Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.