Developing Gadgets for Websites

What is a Gadget ?

In software world, Gadget is a useful plug-in which can be incorporated into any website without much effort, Gadgets can provide functionality such as News, Weather , Photos, fun etc. Best example for gadget powered website is iGoogle.

How to use a Gadget ?

Consider that you run a blog about programming in If you want to show the latest articles published in c-sharpcorner you need to write a program to read the RSS feed provided by Instead of  that you can use some online RSS reader gadget and make your life simple.
Copy paste the below HTML tag in your blog / website it will do all the job for you, Is that not simple..?

<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"> </iframe>


How to code a Gadget ?

 Gadget can be written in any language like HTML, JavaScript , ASP.Net , Java , Silverlight, Flash. But the final outcome of the gadget should be able to render itself in a web page. Let us code a  gadget to read the articles from c-sharpcorner RSS and display it in our blog / website. In the below example I have used google's feed reader to read the feed from other website. If you are new to Google API's please check this link
Since  cross domain  XML request is not allowed by http standards I'm using google api which read feeds from any web server and returns in json format.

HTML Code (gadget.htm)

<body onload="javascript:ReadFeed();">
<div class="mainDiv" id="mainDiv">
   <div class="hr" id="h1">
          <span class="ndLink">&nbsp;&nbsp;<a href="http://www.newsdabba.comtarget="_blank"
           title="News  Dabba, All news in one website - Sridhar Subramanian"></a></span>    
          <span class="ndHead"></span>
    <div class="ct" id="ct"></div>

Javascript Code:(gadget.htm)

    <!-- Refer Google api-->
    <script  type="text/javascript" src=""></script>
    <!-- Which service you like to use, for more information checkout -->
    <script  type="text/javascript">google.load("feeds", "1");</script  >    
    <script  type="text/javascript">

        function ReadFeed() {
                //Adjust the height of artilce based on iframe's attribute
                document.getElementById("mainDiv").style.width = document.body.parentNode.clientWidth - 15 + "px";
                document.getElementById("mainDiv").style.height = document.body.parentNode.clientHeight - 25 + "px";
                var feed = '';
                //Set the URL you want to read
                var gFeed = new google.feeds.Feed('');
                //Number of feed to load
                //Start loading the feed
                gFeed.load(function(result) {
                    if (!result) {
                           return false;//if fails
                      for (var i = 0; i < result.feed.entries.length; i++) {//if success loop through the feed and display
                        var entry = result.feed.entries[i];
                        feed = feed + '<div style="padding-bottom:4px;"><a href="' + + '" target="_blank">' + entry.title + '</a></div>';
                    document.getElementById("ct").innerHTML = feed;
    </script >    

In the above gadget  user setting such as width & height is set by reading the attributes  passed by the user in iframe element

document.getElementById("mainDiv").style.width = document.body.parentNode.clientWidth - 15 + "px";

Apart from this you can set other user preferences such as Color , Theme , Feed Count, Custom message  by taking these variable as input parameter in query string.  Also you need to make sure that gadget does not occupy much space of the website and it has to work on all major browsers and resolutions.To access the developed gadget it  has to be hosted in publicly accessible website. The gadget which is mentioned above can be access through below html element from a different page (TestGadget.htm)

<iframe src="gadget.htm" title="" frameborder='0' scrolling="no" width="300px" height="200px"> </iframe>

Below are some useful gadgets which you can use in your blog  / webpage.

World news:
<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"></iframe>

India news:
<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"></iframe>


<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"></iframe>

<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"></iframe>

<iframe src=""
 title="" frameborder='0' scrolling="no" width="300px" height="200px"></iframe>

Also check how google gadgets are shown in  toolbar, Please download the source code for working sample. Any comments regarding this article is welcome.