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 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
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 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
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 November 21st 2011, 10:45 am

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 November 21st 2011, 10:51 am

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 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
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 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>");
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 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.
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 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

Sanket
Sanket
ForumGuru

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

Back to top Go down

Back to top

- Similar topics

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