Wednesday, July 9, 2008
Suppress IE window closing message
When clicked IE displays the message "The web page you are viewing is trying to close the window. Do you want to close this window".
Javascript code
Javascript code
<script language="javascript">
function close_me()
{
window.opener = top;
window.close()
}
</script>
Thursday, July 3, 2008
Javascript - Truncate text after certain number of charecters
Here is the peice of javascript code which can be used to truncate all the texts in a HTML page after certain number of charecters:
function truncateText(tagid, size)
{
var allTdElements = document.getElementsByTagName('td');
for(var j=0; j < allTdElements.length ; j++)
{
var tempTdData = '';
var lineSeparator = '<BR>';
if (allTdElements[j].id == tagid)
{
var tdData = allTdElements[j].childNodes[0].innerHTML;
var arrayOfStrings = tdData.split(lineSeparator);
for (var k=0; k < arrayOfStrings.length; k++)
{
if(arrayOfStrings[k].length > size)
{
if(tempTdData.length > 0)
tempTdData += lineSeparator + arrayOfStrings[k].substr(0,size) + '...';
else
tempTdData += arrayOfStrings[k].substr(0,size) + '...';
}
else
{
if(tempTdData.length > 0)
tempTdData += lineSeparator + arrayOfStrings[k].substr(0,size);
else
tempTdData = tempTdData + arrayOfStrings[k].substr(0,size);
}
}
allTdElements[j].childNodes[0].innerHTML = tempTdData;
}
}
}
Saturday, June 28, 2008
Tuesday, June 24, 2008
Subscribe to:
Posts (Atom)