Addressing the *Home* folder - javascript [modified], Yes question revamped.
-
How do I address a home folder in javascript? like from a sub directory, I would want to open a document from the directory, by giving a relative path.
document.open("~/myfolder/mydoc.htm");
To be precise, I'm generating the script itself. like
obj = "<a href="~/myFolder/mydoc.htm">click";
</a>More clarifications
Home: Webroot
Where I am now : Webroot/MyPages/MyLittlePages/SPage.htm
Where I am now : Webroot/MyPages/MyBiggerPages/SPage.htmWhere I want to go: Webroot/TargetPage/Tpage.htm
From SPages, I want to open a doc in TargetPage. And I'm writing a common script generator that gets added as inner HTML. So no matter where I am, I should be able to call the script that expands the code & be able to open the doc. here the "~" doesn't work. So everytime I'm hard coding the rootweb address. That totally sucks. Anybody help. Thanks.
:beer:
modified on Friday, February 27, 2009 5:35 AM
-
How do I address a home folder in javascript? like from a sub directory, I would want to open a document from the directory, by giving a relative path.
document.open("~/myfolder/mydoc.htm");
To be precise, I'm generating the script itself. like
obj = "<a href="~/myFolder/mydoc.htm">click";
</a>More clarifications
Home: Webroot
Where I am now : Webroot/MyPages/MyLittlePages/SPage.htm
Where I am now : Webroot/MyPages/MyBiggerPages/SPage.htmWhere I want to go: Webroot/TargetPage/Tpage.htm
From SPages, I want to open a doc in TargetPage. And I'm writing a common script generator that gets added as inner HTML. So no matter where I am, I should be able to call the script that expands the code & be able to open the doc. here the "~" doesn't work. So everytime I'm hard coding the rootweb address. That totally sucks. Anybody help. Thanks.
:beer:
modified on Friday, February 27, 2009 5:35 AM
-
Yes, thanks I meant the home folder. But "~" doesnt seem to work. So that's the way we do in Javascript?
:beer:
There is no special way to do it in JS - it uses exactly the same URLs as anywhere else on a web page. In this instance I suspect that you don't need to specify ~ at all - this is a syntax that has fallen out of favour and must be followed by a username (~/ just refers to 'a home' directory, not the web root directory, which is /).