Archive for April 15th, 2009

Convert HTML entities from XML in JavaScript

Sometimes you get passed a string from XML and it can contain HTML entities like the following

&
<
>
"
©
®
«
»
'

If you write the string with JavaScript then you get something like didn't instead of didn’t

I’ve searched around for a function that could handle this but could not find one, so I wrote my own. I thought I’d share it with the world!

The following will convert & to &, convert ' to ‘ etc.

Following is the code, if you need help implementing it, I’m more than happy to explain how you install and run this function in return for a text link on your website, now that’s cheap as, considering I normally charge $140 an hour ;-)

String.prototype.trim = function () {
	return this.split( /\s/ ).join( " " );
}
String.prototype.convertHTMLEntity = function () {
	var myString = this;
	myString = myString.replace( /\&/g, '&' );
	myString = myString.replace( /\&lt;/g, '<' );
	myString = myString.replace( /\&quot;/g, '"' );
	myString = myString.replace( /\&copy;/g, '©' );
	myString = myString.replace( /\&reg;/g, '®' );
	myString = myString.replace( /\&laquo;/g, '«' );
	myString = myString.replace( /\&raqou;/g, '»' );
	myString = myString.replace( /\&apos;/g, "'" );
	return myString;
}

Add comment April 15, 2009

Facebook advertising

We’ve been advertising online on facebook for a while and have been seriously disappointed with the results so far. Just wondering if anyone else is experiencing the same results?

Taking the web statistics for this month

facebook.com
20 visits
Avg. time on site: 00:00:00
100% new visits
100% bounce rate

Nowhere else in our statistics have we got a bounce rate of 100% or average time on site of zero, and I mean nowhere. It almost feels as if these are automated visits.

Would love to hear from others out there using facebook for advertising?

Add comment April 15, 2009


Email Subscription

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Categories

Archives

Recent comments

Blogroll

Top Rated

Top Clicks

Category Cloud

Advertising Brisbane SEO clickfind Business Directory ColdFusion Environmental initiatives Google Google Adwords Google Analytics In the media JavaScript JavaScript Form Validation Marketing MS SQL Other Programming Search Engine Optimization & Marketing Yahoo

Tags

alexa alexa ranking analytics anchor text links australia Australian Search Engines bartercard base bbx brisbane business directories business directory business directory review cfc clickfind ColdFusion forum gadget Google hash html internet traffic keywords list local search markup MS SQL online marketing pagerank PR Programming RSS search engine search engines security SEO spellcheck spelling stored procedure tool trust tutorial validation website design www.mergermarket.com

Blog Stats

Top Posts

Authors

RSS Start Listing