www.webdeveloper.com
Results 1 to 3 of 3

Thread: Navigation bar and location

  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Question Navigation bar and location

    I am working on my website and am having trouble with the navigation bar. I am using Javascript to write innerHTML and if statements for finding what page I am on. Currently I am trying to figure out how to find out the document name so i could do something like:

    Code:
    function navigate() {
        var current = location.pathname;
    
        if (current == 'W:\public_html\index.htm') {
    but without the full pathname. So that it would be
    Code:
    (current == 'index.htm')
    Does anyone know how to get just the document name? Thanks in advance!

  2. #2
    Join Date
    Nov 2010
    Posts
    2
    Sorry for the double post here but I semi figured it out I think. I changed it to window.location.href and just put the full URL in it. Like this:

    Code:
    function navigate() {
        var current = window.location.href;
    
        if (current == 'http://jupiter.clarion.edu/~s_mrondo/index.htm') {...}
    This fixes it I think but I'm still curious to know if there's a different way

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    if (current.indexOf('index.htm')!=-1) {
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles