www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] innerHTML - remove http:// from link

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Posts
    88

    resolved [RESOLVED] innerHTML - remove http:// from link

    Hi.

    I have a dynamically generated link on a page which I would like to change from being displayed as http://www.website.com to just www.website.com.

    The code is:

    HTML Code:
    <a href="http://www.website.com" target="_blank" id="link">http://www.website.com</a>
    I would like to change it to:

    HTML Code:
    <a href="http://www.website.com" target="_blank" id="link">www.website.com</a>
    There are other links on the page which should be left untouched. Can anybody help out with a script which removes http:// from the link with this specific id?

  2. #2
    Join Date
    Jan 2010
    Location
    Cambridge, UK
    Posts
    42
    Easiest way would be to just replace the http:// with an empty string. Something like:

    Code:
    document.getElementById("link").innerHTML = document.getElementById("link").innerHTML.replace("http://","");
    Last edited by iandevlin; 02-10-2010 at 04:45 AM.

  3. #3
    Join Date
    Dec 2004
    Posts
    88
    Hi.

    Works perfectly - thanks.

    Regards.

  4. #4
    Join Date
    Jan 2010
    Location
    Cambridge, UK
    Posts
    42
    Welcome!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles