Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3798184
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:31:50+00:00 2026-05-19T13:31:50+00:00

I am trying to make a hyperlink on every url in my page. There

  • 0

I am trying to make a hyperlink on every url in my page.
There is code like this:

<div id="divC">
       Hello testing message 
       My profile link : http://stackoverflow.com/users/568085/abhishek and 
       my user account link : 
    <a href="http://stackoverflow.com/users/568085/abhishek">
    <img height="58" width="208" title="Stack Overflow profile for Abhishek at Stack Overflow, Q&amp;A for professional and enthusiast programmers" alt="Stack Overflow profile for Abhishek at Stack Overflow, Q&amp;A for professional and enthusiast programmers" src="http://stackoverflow.com/users/flair/568085.png?theme=dark">
    </a>
</div>

and I used below javascript function to add link on every URL in content page :

<script>
   //call function for linking every url
    createLinks();
    function createLinks()
    {
        var exp=/(((\b(https?|ftp|file):\/\/))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;     
        $("div#divC").each(function(index) {            
             $(this).html($(this).html().replace(exp, "<a target='_self' class='msg_links' href=$1>$1</a>"));
        });
    }
      </script>

In above code working fine but I don’t want to create link on <img src='www.test.com'>.
when I run this it also created link in the <img src="<a href='www.test.com'>www.test.com</a>" > ,
How can I avoid create link in <img> src.?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:31:51+00:00Added an answer on May 19, 2026 at 1:31 pm

    Ah… I see what you are doing. I’ve did it a while ago, building a plugin that replaces smiley’s :D. Does this code work better?

     //call function for linking every url
        createLinks();
    
    
        function createLinks()
        {
            var exp=/(((\b(https?|ftp|file):\/\/))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;     
    
    
            $("div#divC")
            .contents()
            .filter(function () {
    
                if (typeof (Node) == 'undefined') {
                    return this.nodeType == 3;
                }
                else {
                    return this.nodeType == Node.TEXT_NODE;
                }
            }).each(function(index) {  
    
                var x = $(this)[0].nodeValue;
                if (x != '') {
                   x = x.replace(exp, "<a target='_self' class='msg_links' href='$1'>$1</a>");
                   $(this).replaceWith(x);
                }
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I'm trying make this code which is from a Dictionary of Arrays (CODE) from
I'm just trying to make a hyperlink (which is the div .t2 ) appear
Trying to make a custom :confirm message for a rails form that returns data
trying to make a page which will recursively call a function until a limit
Trying to make a floating css menu. How do I get the floating div
I'm trying to make a Hyperlink that contains text with super- and/or subscripts. I've
I'm trying to make a url in an XML file show up on an
I'm new to jquery and i'm trying to make a dropdown menu list like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.