Jump to content

How to make certain words an automnatic link?


pioneerx01

Recommended Posts

I can not seem to be able to get it to work. Where exactly should I place this code. I tried both in header and body, but none works.

 

I am new to PHP, but what exactly defines "$content" Would I have to recode my paragraphs as

$content = paragraph Chicken paragraph;
echo "$content";

Link to comment
Share on other sites

Im assuming $content is the content (text you want auto links generated from) before it is output on the screen. However I guess your website isn't set up that way.

 

Doesn't matter, because you can do it in Javascript anyway ^^ . Have a look at http://stackoverflow.com/questions/1774269/auto-link-specific-words-and-phrases and http://psoug.org/snippet/Javascript-Auto-Link-words_113.htm

Link to comment
Share on other sites

Hi,

 

I have looked at both links (as thoroughly as I know how) but I can not get either working. I know nothing about Javascript, which is probably why I can not get it to work.

 

<html>
<head>
<script type="text/javascript">
FUNCTION linkWord(obj){
  FOR(i IN obj){
    VAR x = document.body.innerHTML;
    VAR linkStart = '<a href="'+obj[i]+'">';     
    VAR linkEnd = '</a>';     
    VAR reg = NEW RegExp ('\\b' + i + '\\b','g');
    x = x.replace(reg, linkStart + i + linkEnd);
    document.body.innerHTML = x;
  }
}
</script>
</head>
<body>
<p>Check out these cables!</p>
</body>
</html>

 

Where do I place:

 

'cables':'http://www.google.com',

 

to make cables as hyperlink to a site (Google in this example)?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.