We help IT Professionals succeed at work.

Javascript hyperlinks

VBBRett
VBBRett asked
on
Medium Priority
266 Views
Last Modified: 2012-06-21
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!
Comment
Watch Question

Commented:
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.

Author

Commented:
can you just put folder/page.htm as opposed to /folder/page.htm?

Commented:
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.

Author

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?

Commented:
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

Author

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?
Kusala WijayasenaSoftware Engineer

Commented:
Are you looking at a "URL Rewriting" (http://en.wikipedia.org/wiki/Rewrite_engine) solution ?

-Kusala

Author

Commented:
Not necessarily so.  I would like to manually do this so that I can just redirect the links to the appropriate place.  Thanks!

Commented:
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.
Software Engineer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.