Domain Manage

Simple Javascript help

Discussion in 'Website Design' started by aquanuke, Oct 18, 2007.

Thread Status:
Not open for further replies.
  1. aquanuke

    aquanuke Well-Known Member

    Joined:
    May 2005
    Posts:
    2,017
    Likes Received:
    34
    Hiya I have

    PHP:
    <script>
    document.write(window.location.hostname)
    </script>
    Which would display www.domain.com

    but I would like to strip out the www. bit so it only displays domain.com

    How would I do that.

    Thanks
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. stevebrowne

    stevebrowne Active Member

    Joined:
    May 2007
    Posts:
    878
    Likes Received:
    11
    You should be able to use the replace function,

    something like

    document.write(window.location.hostname.replace(/www./i,''))
     
  4. aquanuke

    aquanuke Well-Known Member

    Joined:
    May 2005
    Posts:
    2,017
    Likes Received:
    34
    Thanks have sorted it
     
Thread Status:
Not open for further replies.

Share This Page