[Javascript] Includes and relative paths?

Ben Curtis Quixote at LaMancha.org
Tue Jul 3 11:23:53 CDT 2001


> OK, I have a page link in an include file, "/dir1/dir2/page1.asp".
> 
> The include file is in a page at "/dir1/dir3/page2.asp".
> 
> The include file is at "/include/inc_menu_bar.asp".
> 
> When I click the link, where does it 'think' it is?  My testing has left me
> somewhat more befuddled than usual.  What I need is to have the include file
> produce the called page regarless of where it is when the link is clicked.  I
> can do it by using "http:// . . .", but I'd like to avoid that because of
> development issues.  I don't want to have to rewrite all the links in order to
> move the pages to production.


To the browser, there is no such thing as an include. Once the server
"includes" the file, the browser only sees plain HTML -- and can't tell the
difference between HTML that was completely coded as-is or HTML that was
assembled from code fragments.

Thus, your browser will react to the link to "/dir1/dir2/page1.asp" on the
page of "/dir1/dir3/page2.asp" as if you simply coded that link onto that
page. The include is confusing you. Let it go... :)

+Ben Curtis
...just this guy, you know?










More information about the Javascript mailing list