Solved

Add Target Attribute to a Link

Posted on 2010-09-23
4
507 Views
Last Modified: 2012-05-10
Greetings

I am trying to add the target attribute to links in an rss feed.

Here is my code:

<cfset rssContent = REReplace(rssContent,'<a href="http://[^"]+">','<a href="http://[^"]+" target="_blank">','ALL')>

It is adding the target attribute but it's destroying the link information.

Thanks
0
Comment
Question by:RayBakker
  • 2
4 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 33745597
Try this:
<cfset rssContent = REReplace(rssContent,'(<a href="http://[^"]+")>','\1 target="_blank">','ALL')>

Open in new window

0
 
LVL 36

Expert Comment

by:SidFishes
ID: 33745673
or you can simply replace the closing >

<cfset out = replacenocase(rssContent, ">",  " target=""_blank"">","ALL")>


btw - in either case you should use the replaceNoCase or reReplaceNoCase if you don't have control of the source of the input as replace is case sensitive it will miss

google.com vs Google.com

0
 

Author Closing Comment

by:RayBakker
ID: 33747342
Works perfectly. Thank you.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 33748605
NP. Glad to help  :)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now