Javascript hyperlinks

Hello, I am looking to use javascript hyperlinks and as opposed to linking directly to the site and using the http://www.thissite.com/thislink/ formation, I would prefer to use a reference to the local files no matter where it the site is.  How would I do that?  Here is an example of one of the lines that I would like to change:

pageMenu_23.addMenuItem("About Braces","location='http://www.blahblah.com/d/topic1/about-us'");

How would I change this to a link that refers to a file that is one of the local files no matter where the site is located?  Thanks!
VBBRettAsked:
Who is Participating?
 
Kusala WijayasenaConnect With a Mentor Software EngineerCommented:
As megaman5 explained in his comment (ID:35481129), I also think you can accomplish your task by using "Root-relative Hyperlinks". Isn't it ?

-Kusala
0
 
megaman5Commented:
Local files meaning the HOST of the website?  use absolute (root) links, like this:

/folder/page.htm

This will make the browser assume
http://www.thedomainthispageison.com/folder/page.htm

Thanks.
0
 
VBBRettAuthor Commented:
can you just put folder/page.htm as opposed to /folder/page.htm?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
megaman5Commented:
If you do that, it will assume relative to the current directory, not the root of the site.

For example: lets say the current page is http://www.test.com/something/page.htm

folder/page.htm would be http://www.test.com/something/folder/page.htm
/folder/page.htm would be http://www.test.com/folder/page.htm

Thanks.
0
 
VBBRettAuthor Commented:
OK, I see.  How about if you are at a link say the following:

http://www.rootdirectory.com/folder/page.html

and from page.htm, you want to reach the following link:

http://www.rootdirectory.com/topic/page.html, how would you go to topic/page.html?
0
 
megaman5Commented:
As long as it is in the root (aka right after .com)

/topic/page.html

Just to give you more options, .. means up a directory, for example

../topic/page.html

would mean go up a directory, then into the folder topic, then page.html

If you were on this page:  http://www.rootdirectory.com/folder/anotherfolder/page.html
and you used the link:  ../topic/page.html
it would go to: http://www.rootdirectory.com/folder/topic/page.html
0
 
VBBRettAuthor Commented:
So how do you go to the root directory from http://www.rootdirectory.com/folder/anotherfolder/page.html

if you wanted to go to the following:

http://www.rootdirectory/differentfolder/differenttopic/page.html?
0
 
Kusala WijayasenaSoftware EngineerCommented:
Are you looking at a "URL Rewriting" (http://en.wikipedia.org/wiki/Rewrite_engine) solution ?

-Kusala
0
 
VBBRettAuthor Commented:
Not necessarily so.  I would like to manually do this so that I can just redirect the links to the appropriate place.  Thanks!
0
 
megaman5Commented:
http://www.rootdirectory/differentfolder/differenttopic/page.html?

Than use this


/differentfolder/differenttopic/page.html

If it start with a slash, it a assumed that it right after the domain name.
0
 
megaman5Connect With a Mentor Commented:
Yes,

Root-Relative   /link/link.htm
Document-Relative  link/link.htm
absolute http://www.domain.com/link/link.htm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.