Content Syndication using Dynamic Javascript


In the
previous post
we saw how to use RSS to syndicate your web content. If you want to syndicate your
content for other web sites, this method demand work from the consumer work site in terms of reading
the feed and interpreting it. An alternate method, is content syndication using dynamic javascript.

This example show you how,
The site that consumes your content will include a block of script like this where ever they want your
content to be shown,


<SCRIPT SRC="http://www.directkerala.com/syn/js.aspx?js=y"> </SCRIPT>

When the webpage is rendered it calls this page in your web site to render the content. In your
web site ( In our example, js.aspx ), you will add code similar to this,

private void Page_Load(object sender, System.EventArgs e)
{
if (Request["js"] == "y")
{
Response.ContentType = "application/vnd.javascript";
Response.Write ("document.write('");
Response.Write ("<a href=http://www.directkerala.com><img border=0 src=http://www.directkerala.com/images/dklogohome.jpg>");
Response.Write ("</a>')");
Response.End();
}
}

Please take a note of the MIME[Content] type here, it is set as “application/vnd.javascript”. This will enable dynamic
javascript and your “document.write” will write the html you have embedded within. This is a very effective way of providing
content and attracting users to your site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s