O'Reilly logo

Amazon Hacks by Paul Bausch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Add Pop-up Amazon Reviews to Your Web Site

With a few lines of JavaScript, you can add Amazon customer reviews to your web site.

The Amazon pop-up review service is a simple yet powerful way to integrate your site with Amazon. It allows anyone with a web site to generate dynamic customer reviews without needing to know anything about Amazon’s API (see Chapter 6). An independent developer has provided this service to anyone who would like to use it.

All you need to set up the service on your site is a product’s ASIN [Hack #1]. When a visitor clicks the pop-up review link, the application receives the ASIN, connects to Amazon’s API, downloads the specific XML data, and parses through it to build the product page with reviews. The data is then displayed on a stylized web page in a new browser window.

The Code

Displaying the generated code in a pop-up window takes just two easy steps. First, create a new HTML page and paste the following JavaScript between the <head></head> tags. This code creates a function called AmazonLookup that will control the state of the pop-up window and initiate a link to the remote server.

<script type="text/javascript"> function AmazonLookUp(ASIN) { // Set pop-up window properties var winoptions = 'toolbar=no,'; winoptions += 'menubar=no,'; winoptions += 'location=no,'; winoptions += 'scrollbars=yes,'; winoptions += 'resizable=yes,'; winoptions += 'statusbar=yes,'; winoptions += 'width=470,'; winoptions += 'height=500'; //Set the remote service URL, including ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required