dcsimg
Results 1 to 2 of 2

Thread: How to modify this code to add more clickable links to it?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    50

    How to modify this code to add more clickable links to it?

    Hi all,
    I have this code from here
    http://www.vbforums.com/showthread.p...15#post5335515
    Here the code
    Code:
    <script>
           function sendFunction() {
               var userName = document.getElementById("myUserName").value;
               var userinput = document.getElementById("myInput").value;
               var imagesrc = document.getElementById("baseimage");
     var img = $('<img width=" =100px;" height=" 100px">').attr('src', imagesrc.value);
            
        $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
        $('#conDivID').append("<span style='color: blue'>" + embedUrls(userinput) + ' </span>');
        $('#conDivID').append('</br>');
        $('#conDivID').append("<span class='timeSpan'>" + timestring + '</span>');
                   $('#conDivID').append('</br>');
                   $('#conDivID').append(img);
                   $('#conDivID').append('</br>');
                   
    
                  
               }
    
        function embedUrls(text) {
            var urlRe = /(https?:\/\/[^\s]+)/g;
            return text.replace(urlRe, '<a href="$1">$1</a>');
        }          
    </script>
    And I try it and it works as it say.
    But is
    it possible to :-
    1-Make it open in a new window " target="_blank"?
    2-Include the code links end with .com,.net,.org,.om,.us,.uk,.sa,.gov etc.
    such as"google.com"?
    3-Make it open phone numbers if user uses my site on his mobile and send phone number it should be clickable ?
    4-Include it email address to be clickable.



    Thanks for your valuable time
    Last edited by Max45; Nov 28th, 2018 at 06:51 PM.

  2. #2
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,142

    Re: How to modify this code to add more clickable links to it?

    For #1, #2, and #4, what have you tried? The code already looks like it would work for .com, .net, .org, etc. Have you tried it?

    Have you read and understood the code? If you're familiar with HTML at all, there is one line in that code that should make it extremely obvious how to add the target="_blank" to the anchor.

    You also shouldn't make a double post. Your previous reply to the other thread wasn't answered because you didn't specify enough information and because you didn't actually try anything yourself.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width