Forum Moderators: open

Message Too Old, No Replies

creating links using JS

creates links based on words

         

luckydude

8:13 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



I am working on a project where we are using a lot of names of hospitals and everytime we use the name, my client wants to link them to their appropriate URL.

But it's kind of hard for me to have a link tags all the time. So I was wondering if there is anyway I can write a script that will attach a link to the word everytime it's mentioned on the body of the page.

Your help is greatly appreciated. Thank you.

-luckydude

whoisgregg

2:54 am on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you are trying to do would be very similar to a search engine word highlighter. (Like when you view Google cached pages or come to WebmasterWorld from a search engine.) Typically this is done server side with perl or php, but there are javascript example scripts out there if you look (I found some with "javascript word highlight").

You'll need to look into the code and replace where it parses the referrer info and replace that with your specific phrase and also change the part of the code that wraps the text with <font ...> tags and instead wrap the text with <a href...> tags.

It may be important that the links it creates probably won't count as links for search engines... :)

Hope this helps!

luckydude

4:03 pm on Nov 4, 2004 (gmt 0)

10+ Year Member



Thanks whoisgregg. I didn't know it was that simple. I will look for it. As far as searh engines finding the links generated by JS, it's not a problem. It's okay if they don't find it. Thanks again.

- Luckydude

whoisgregg

4:44 pm on Nov 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Happy to help. :)

adni18

4:13 pm on Nov 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could always use a universal javascript import at the top of the page, which replaces(with RegExp) all the instances of, say "apple" with "<a href="ourpages/19379027298.html">apple</a>" or something like that. Check it out.