Account Options

Help

Developers » Web Developers » Code

Sample Code

Using BrowserPlus™ is simpler than you might think. We've created some samples to demonstrate how simple. If BrowserPlus is installed, you'll be also be able to run the samples on this page.

 1

Introduction

Check for and initialize BrowserPlus.

 2

Detecting BrowserPlus

How to detect if BrowserPlus is installed.

 3

Using Services

How to specify in your webpage what BrowserPlus services you require.

 4

Errors & Return Values

How results are asynchronously returned.

 5

Drag and Drop

Hooking up a drop target in a webpage.

 6

Accessing Files

Previewing and getting contents of files that users select.

 7

Uploading Modified Images

A demo showing how to use ImageAlter and Upload in a chain to upload images altered on the client.

 8

File Zipper

A demo showing how to use Zipper and Upload in a chain to compress all files into one *.zip file before uploading.

 9

All About Uploading

A demonstration of the various features of the uploader service.

10

Image Twiddler

A complete web application that demonstrates client side image manipulation, tying together the concepts thus far.

11

Publish Subscribe

Shows how two different browser windows (even from different browsers) can send messages back and forth.

Detecting BrowserPlus

Description

This code sample demonstrates how you can detect whether BrowserPlus is installed. Inline comments describe the four possible cases when you call BrowserPlus.init():

  1. BrowserPlus is installed and ready to use: r.success === true.
  2. BrowserPlus is not installed and client platform is supported, r.error === 'bp.notInstalled'.
  3. BrowserPlus is not installed and client platform is NOT supported, r.error === 'bp.unsupportedClient'.
  4. Otherwise, BrowserPlus encountered an error during initialization.

The last two cases should be considered failure cases, and as a developer you should disable BrowserPlus functionality. In the second case you can render a link pointing to http://browserplus.yahoo.com/install, and describe to your user what features will become available to them if they install BrowserPlus. Further, if you would like to automatically detect when BrowserPlus is installed without a page reload you can use the BrowserPlus.initWhenAvailable() platform function which will set up a poller and once init() completes successfully, will invoke the callback you provide.

Using this handful of tools it should be possible to craft the precise experience you're looking for.