Intelligence Information Technology Communication : raviramanujam@gmail.com

Wednesday, July 28, 2010

Google Gadget Basics

Google Gadgets are fragments of HTML wrapped in custom Google XML tags. You can include JavaScript in the HTML, and most gadgets are mostly JavaScript. Each gadget has a ModulePrefs tag (one of Google's custom XML tags) that includes its title, description, and author information. Another custom tag called UserPref can save a user's individual settings.

Here is a simple "Hello, World" example, that replaces the word "World" with the user's name if it has been entered into the gadget's settings dialog box:

<?xml version="1.0" encoding="UTF-8"?>

<Module>

<ModulePrefs title="hello world example" />

<UserPref name="userName" display_name="Your Name" default_value="world" />

<Content type="html"><![CDATA[

Hello,

<script>

var thePrefs = new gadgets.Prefs();

var userName = thePrefs.getBool("userName");

document.write(userName);

</script>

]]></Content>

</Module>

A user can enter their name through the settings dialog box. The link to the dialog box ("Edit Settings") is created automatically by iGoogle when it detects that a UserPref tag is present.

No comments:

Indian Temples History.