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.

attach link automatic to some words in the posts

3 posters

Go down

Solved attach link automatic to some words in the posts

Post by PE!N 21/11/2011, 11:37

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 21/11/2011, 21:54; edited 1 time in total
PE!N
PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

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

Post by ankillien 21/11/2011, 12:26

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
ankillien
ankillien
Energetic

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

Back to top Go down

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

Post by PE!N 21/11/2011, 12:45

it's not working with me.
PE!N
PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

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

Post by ankillien 21/11/2011, 12:51

Where did you add the script?
Also post the full code that you added.
ankillien
ankillien
Energetic

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

Back to top Go down

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

Post by PE!N 21/11/2011, 16:30

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
PE!N
PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

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

Post by ankillien 21/11/2011, 17:14

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>");
ankillien
ankillien
Energetic

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

Back to top Go down

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

Post by PE!N 21/11/2011, 21:53

thanx sir attach link automatic to some words in the posts 690335 .. it worked now when i deleted other java codes.
PE!N
PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

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

Post by Sanket 21/11/2011, 21:54

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

Sanket Smile

Sanket
Sanket
ForumGuru

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

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum