Use Javascript To Get Current URL Page

I have some custom javascript functions that are included on all of my web pages; however, a few functions are only intended for the home page. So I decided to use the “window.location” object to determine if the site URL is in fact the home. See example below:

if(window.location==”http://domain.com/”){
// run home page functions
}

Here are a few other helpful JavaScript objects that expose site locations:

  1. hash: Returns the anchor portion of a URL
  2. host: Returns the hostname and port of a URL
  3. hostname: Returns the hostname of a URL
  4. href: Returns the entire URL
  5. pathname: Returns the path name of a URL
  6. port: Returns the port number the server uses for a URL
  7. protocol: Returns the protocol of a URL
  8. search: Returns the query portion of a URL

Javascript Enabled Warning Message

How to detect if a browser’s javascript is enabled or disabled and display a message.
Continue Reading »

Javascript Non Alphanumeric Characters Regex

Using javascript regular expressions to stop users from entering non-aphanumeric characters or white spaces
Continue Reading »

Javascript Email Validation Form

Check user email address forms to make sure they are valid using JavaScript before saving their info. The JavaScript code is provided here.
Continue Reading »

Javascript Go Back to Previous Page Button Link

Go Back javascript history button links to allow visitors to go back to previous page. Here the free javascript code.
Continue Reading »

Javascript Center Popup Window

How to center a chromeless pop-up window in most browsers.
Continue Reading »

Popup Chromeless Window

An easy to use Javascript Popup Chromeless Window.
Continue Reading »

Alert Boxes

Alert boxes are small popup boxes that are triggered by user events. Here are a few good examples on how to alert your users.
Continue Reading »

overLIB

overLIB is a JavaScript library created to enhance websites with small popup information boxes (tooltips) to help visitors around your website.
Continue Reading »

Delete Warning

Javascript that alert users when clicking on sensitive links (like delete or update links). You can customize the message with option to continue or cancel. Works great with PHP, ASP, and Perl administration sites.
Continue Reading »

Page 1 of 212