Generating URL

Discussion in 'Mac Programming' started by macbaseball, May 11, 2005.

  1. macrumors 6502a

    macbaseball

    Joined:
    Feb 27, 2005
    Location:
    Northern California
    #1
    I'm trying to figure out how to generate a URL which then would be a link.

    What I want to do is only change the middle part of a URL. Most of the codes I'm seen only can change the end of the URL. Could someone help me out.
     
  2. macrumors 68030

    superbovine

    Joined:
    Nov 7, 2003
    #2
    would you care to elaborate on what language you would be doing your project in?
     
  3. thread starter macrumors 6502a

    macbaseball

    Joined:
    Feb 27, 2005
    Location:
    Northern California
    #3
    I'm trying to make a widget, so probably Javascript, or HTML.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Basically you are on your own. If you are using the window.location object you can get the various parts of the URL:

    If your document is at http://myhost.com:8080/my/folder/path/document.html?search=test#fred

    hash: returns #fred
    host: returns myhost.com:8080
    hostname : returns myhost.com
    href: the entire text
    pathname: returns /my/folder/parh/document.html
    port: returns 8080
    protocol: returns http:
    search: returns ?search=test

    Notet that these are read/write so you can do (say) window.location.path = '/my/new/path/page.html';

    If you just have a string then it's up to you to parse it.
     

Share This Page