#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Javascript/cfinclude problem


    I don't have my code handy but I'll try to explain the problem. On my site, I have a header.cfm and a leftnav.cfm that are used as includes throughout the site. In leftnav.cfm, I have javascript related to the navigation menu.
    The includes work fine througout the site but if I open a page outside of the directory where the leftnav.cfm is located, the javascript doesn't function. The leftnav shows up(which proves the include is working) but the javascript doesn't.

    If I need to be more specific, I'll post my code this evening when its more easily accessible.

    Just thought someone may be familiar with this issue and could shed some light on it.

    Thanks in advance
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    You probably need to use an absolute path for your JavaScript source..
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by kiteless
    You probably need to use an absolute path for your JavaScript source..
    Thanks for the quick reply. I'm sure that's it. It was late and the js source path never crossed my mind.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by ballyhoo
    Thanks for the quick reply. I'm sure that's it. It was late and the js source path never crossed my mind.
    Found this explanation on another site:
    "The included file is considered to be running in the context of it's parent page. The server essentially takes the content of the included file and pastes it into the parent file.
    Your best bet with includes is to use root-relative paths to ensure that paths always point to the proper location..."


    Thanks again.
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,263
    Rep Power
    968
    Also I have to point out that if you would have just taken 30 seconds to look at a Firebug or Chrome developer tools console, it would have instantly shown you the problem.

    I'm happy to help, but next time please take at least a minimal amount of time to investigate the problem before you ask others for help. It can save both of us some time, so it's a win-win.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by kiteless
    Also I have to point out that if you would have just taken 30 seconds to look at a Firebug or Chrome developer tools console, it would have instantly shown you the problem.

    I'm happy to help, but next time please take at least a minimal amount of time to investigate the problem before you ask others for help. It can save both of us some time, so it's a win-win.
    much obliged

IMN logo majestic logo threadwatch logo seochat tools logo