Embedding applications with Javascript
RightCart is a cool service that allows you to embed a shopping cart into your webpage. It looks great, but I think it should be a little bit easier to set up.
When you create an account, you get a small piece of HTML to add to your web page (I’ve added formatting for clarity):
Above the code is the following text:
Simply add the three lines of code below to your web page and your RightCart will appear on your site. It’s that easy.
But why three lines? Let’s look at the information this application needs. I see a div with a the class ‘rightcart_div’, followed by a variable ‘rightcart_pid’ and after that an URL for a piece of JavaScript. In Rhubarb we do the same with a single line of code:
So why is this shorter? We don’t need a named div because our javascript adds it to the page. We don’t need to set a user id of some sort because it’s in the URL. That leaves a single script tag.
Even better, the full code contains a link to a full-page version of the same content for when JavaScript is not available:
It can be dangerous to add HTML to other pages like this. The injected HTML could end up in biggest case of tagsoup you’ve ever seen, completely breaking your layout.
That’s why we offer four different ways to publish an appeal with Rhubarb: a regular page, embedded on another page inside an iframe, embedded inline and embedded with a nice lightbox effect.
This way you can choose the delivery type that best fits your site while keeping everything accessible.