Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Addressing the *Home* folder - javascript [modified], Yes question revamped.

Addressing the *Home* folder - javascript [modified], Yes question revamped.

Scheduled Pinned Locked Moved Web Development
questionjavascripthtmltoolshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Smith
    wrote on last edited by
    #1

    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.htm

    Where 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

    J 1 Reply Last reply
    0
    • S Smith

      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.htm

      Where 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

      J Offline
      J Offline
      Johnny
      wrote on last edited by
      #2

      No, ~ is a home directory. The root folder is just the slash /

      S 1 Reply Last reply
      0
      • J Johnny

        No, ~ is a home directory. The root folder is just the slash /

        S Offline
        S Offline
        Smith
        wrote on last edited by
        #3

        Yes, thanks I meant the home folder. But "~" doesnt seem to work. So that's the way we do in Javascript?

        :beer:

        J 1 Reply Last reply
        0
        • S Smith

          Yes, thanks I meant the home folder. But "~" doesnt seem to work. So that's the way we do in Javascript?

          :beer:

          J Offline
          J Offline
          Johnny
          wrote on last edited by
          #4

          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 /).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups