Jan 28, 2010

Limit the Displayed text in datalist or gridview

Solution:

Eval("description").substring(0,x)

here 'x' displayed limited characters.

Jan 6, 2010

Play swf files using javascript

javascript:
var str;

function display(name)
{
var elementId="charId";
str= swf object source here;

//First check for installed version of Flash Player - we need a minimum of 6
if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){ if (this.autoInstallRedirect==1){ //If we can auto redirect to install the player? var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same."); if (installationConfirm){ window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"; }else{ return false; } }else{ //Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link). //So, expect the developers to provide a course of way to their end users. //window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. "); return false; } }else{ //Render the chart var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = str; //Added
compatibility
//Check if it's added in Mozilla embed array or if already exits
if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id'));
//or else document.forms[formName/formIndex][chartId]
return true;
}
}

inhtml u call the method of javascript.

in body u can call: onload="display('charId')

a href="Javascript:display('Flash-Clock-103.swf')
a href="Javascript:display('OnlinePatentSearch.swf')

div id="charId" align="center"

show xml data in html using javascript

javascript:

var xmlDoc;
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else // Internet Explorer 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET","cd_catalog",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;

var x=xmlDoc.getElementsByTagName("CD");

function show(i)
{
artist=(x[i].getElementsByTagName("image")[0].childNodes[0].nodeValue);
//title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);

txt="Artist: "+artist;
document.getElementById("show").innerHTML=txt;
}