[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

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!
0
VBBRett
Asked:
VBBRett
  • 5
  • 4
  • 2
2 Solutions
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
Kusala WijayasenaSoftware 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:
Yes,

Root-Relative   /link/link.htm
Document-Relative  link/link.htm
absolute http://www.domain.com/link/link.htm
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now