www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 02-10-2010, 02:40 AM
    meek meek is offline
    Registered User
     
    Join Date: Dec 2004
    Posts: 57
    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?
    Reply With Quote
      #2  
    Old 02-10-2010, 03:42 AM
    iandevlin's Avatar
    iandevlin iandevlin is offline
    Registered User
     
    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://","");
    __________________
    web :: blog :: twitter :: html5laboratory

    Last edited by iandevlin; 02-10-2010 at 03:45 AM.
    Reply With Quote
      #3  
    Old 02-10-2010, 04:14 AM
    meek meek is offline
    Registered User
     
    Join Date: Dec 2004
    Posts: 57
    Hi.

    Works perfectly - thanks.

    Regards.
    Reply With Quote
      #4  
    Old 02-10-2010, 04:28 AM
    iandevlin's Avatar
    iandevlin iandevlin is offline
    Registered User
     
    Join Date: Jan 2010
    Location: Cambridge, UK
    Posts: 42
    Welcome!
    __________________
    web :: blog :: twitter :: html5laboratory
    Reply With Quote
    Reply

    Bookmarks

    Tags
    innerhtml, replace


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:14 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.