Posts Tagged javascript
Javascript string method prototype ex. Remove(), ReplaceAll(), Trim()
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, “”); };
String.prototype.replaceAll = function(item,replacewith) {
var s = this;
while (s.indexOf(item) >= 0)
s = s.replace(item, replacewith);
return s;
}
String.prototype.remove = function(item) { return this.replaceAll(item, “”); }
function removeTags(str) {
var tags = ["<B>", "<b>", "</b>", "</B>", " "];
for (var i in tags)
str = str.remove(tags[i], “”);
return str;
}
Javascript: Copy to clipboard with or without flash
function copy_to_clipboard(text)
{
if(window.clipboardData)
{
window.clipboardData.setData('text',text);
}
else
{
var clipboarddiv=document.getElementById('divclipboardswf');
if(clipboarddiv==null)
{
clipboarddiv=document.createElement('div');
clipboarddiv.setAttribute("name", "divclipboardswf");
clipboarddiv.setAttribute("id", "divclipboardswf");
document.body.appendChild(clipboarddiv);
}
clipboarddiv.innerHTML='<embed src="clipboard.swf" FlashVars="clipboard='+
encodeURIComponent(text)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
}
alert('The text is copied to your clipboard...');
return false;
}
http://www.webtips.co.in/postimg/clipboard.rar
via: http://www.webtips.co.in/javascript/copy-to-clipboard-with-javascript-on-mozilla-firefox-and-ie.aspx
also: http://code.google.com/p/zeroclipboard/

