Click here to Skip to main content
15,886,799 members
Articles / Programming Languages / Javascript

Communicating from the Browser to a Desktop Application

Rate me:
Please Sign up or sign in to vote.
4.84/5 (28 votes)
17 May 2009CPOL15 min read 141.5K   4.8K   107  
A very simple application that uses text to speech to speak out loud the currently selected block of text in your web browser.
// BrowserSpeak
//
// by Mark Gladding
// Copyright 2009 Tumbywood Software
// http://www.text2go.com
//
// You are free to reuse this code in any commercial or non-commercial work.
//
// A bookmarklet to send a resumespeaking command to the BrowserSpeak application.

var server = "localhost:60024"; // Change the port number for your app to something unique.

_resumeSpeaking();
void 0; // Return from bookmarklet, ensuring no result is displayed.

function _resumeSpeaking()
{
    var image = new Image(1,1); 
    image.onerror = function() { _showerror(); };
    image.src = _formatCommand("resumespeaking"); 
}

function _formatCommand(command)
{
    return "http://" + server + "/" + command + "/dummy.gif" + "?timestamp=" + new Date().getTime(); 
}
    
function _showerror() 
{
    // Display the most likely reason for an error 
    alert("BrowserSpeak is not running. You must start BrowserSpeak first."); 
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions