attach link automatic to some words in the posts Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    attach link automatic to some words in the posts

    PE!N
    PE!N
    Forumember


    Posts : 81
    Reputation : 1
    Language : english - arabic

    Solved attach link automatic to some words in the posts

    Post by PE!N November 21st 2011, 9:37 am

    Hi
    How are u all??

    i've seen in many forums that the forum link automatic attach to some words in the posts .. example:

    before: I walk through the valley of the shadow of death
    after: I walk through the valley of the shadow of death

    so is there any code or trick to do that or similar to it??


    Last edited by PE!N on November 21st 2011, 7:54 pm; edited 1 time in total
    ankillien
    ankillien
    Energetic


    Posts : 5198
    Reputation : 129
    Language : English, XHTML, CSS, JS, PHP, SQL

    Solved Re: attach link automatic to some words in the posts

    Post by ankillien November 21st 2011, 10:26 am

    Hi,

    Here is a JavaScript...

    Code:
    $(function(){

    $('.post .postbody').each(function(){

      var str = $(this).html();
      var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");
      $(this).html(newStr);

    });

    });

    Add it to your forum via javascript code management for all pages.

    Edit this line as per your requirement...

    Code:
      var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");

    Hope it helps Smile
    PE!N
    PE!N
    Forumember


    Posts : 81
    Reputation : 1
    Language : english - arabic

    Solved Re: attach link automatic to some words in the posts

    Post by PE!N November 21st 2011, 10:45 am

    it's not working with me.
    ankillien
    ankillien
    Energetic


    Posts : 5198
    Reputation : 129
    Language : English, XHTML, CSS, JS, PHP, SQL

    Solved Re: attach link automatic to some words in the posts

    Post by ankillien November 21st 2011, 10:51 am

    Where did you add the script?
    Also post the full code that you added.
    PE!N
    PE!N
    Forumember


    Posts : 81
    Reputation : 1
    Language : english - arabic

    Solved Re: attach link automatic to some words in the posts

    Post by PE!N November 21st 2011, 2:30 pm

    Code:
    $(function(){
           
            $('.post .postbody').each(function(){
           
              var str = $(this).html();
              var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");
              $(this).html(newStr);
           
            });
           
            });

    that is the code and it is added in javascript code management for all pages
    ankillien
    ankillien
    Energetic


    Posts : 5198
    Reputation : 129
    Language : English, XHTML, CSS, JS, PHP, SQL

    Solved Re: attach link automatic to some words in the posts

    Post by ankillien November 21st 2011, 3:14 pm

    In above post, I had asked you to edit this line in the code...

    Code:
    var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE_WITH_THIS");

    For example...

    Code:
    var newStr = str.replace(/forum/gi, "<a href='http://forumotion.com/'>Forumotion</a>");
    PE!N
    PE!N
    Forumember


    Posts : 81
    Reputation : 1
    Language : english - arabic

    Solved Re: attach link automatic to some words in the posts

    Post by PE!N November 21st 2011, 7:53 pm

    thanx sir attach link automatic to some words in the posts 690335 .. it worked now when i deleted other java codes.
    Sanket
    Sanket
    ForumGuru


    Male Posts : 48766
    Reputation : 2830
    Language : English
    Location : Mumbai

    Solved Re: attach link automatic to some words in the posts

    Post by Sanket November 21st 2011, 7:54 pm

    Since this thread appears to be solved, I will archive this thread.
    attach link automatic to some words in the posts 2j4t5a8

    Sanket Smile