Link to home
Start Free TrialLog in
Avatar of VBBRett
VBBRett

asked on

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!
Avatar of megaman5
megaman5
Flag of United States of America image

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.
Avatar of VBBRett
VBBRett

ASKER

can you just put folder/page.htm as opposed to /folder/page.htm?
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.
Avatar of VBBRett

ASKER

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?
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
Avatar of VBBRett

ASKER

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?
Avatar of Kusala Wijayasena
Are you looking at a "URL Rewriting" (http://en.wikipedia.org/wiki/Rewrite_engine) solution ?

-Kusala
Avatar of VBBRett

ASKER

Not necessarily so.  I would like to manually do this so that I can just redirect the links to the appropriate place.  Thanks!
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.
ASKER CERTIFIED SOLUTION
Avatar of Kusala Wijayasena
Kusala Wijayasena
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial