Monday, January 17, 2011

Javascript same code

Санаа авхаар зарим нэг script үүд байна

//=======================================================


make flash

function MakeFlash(Url,Width,Height){




check userAgent

var Browser = new Object();


Get Selection 
var textarea = document.getElementById("textarea");
// code for IE
if (document.selection)
{
    textarea.focus();
    var sel = document.selection.createRange();
    // alert the selected text in textarea
    alert(sel.text);
    // Finally replace the value of the selected text with this new replacement one
    sel.text = '<b>' + sel.text + '</b>';
} else {   
// code for Mozilla
  var len = textarea.value.length;
   var start = textarea.selectionStart;
   var end = textarea.selectionEnd;
   var sel = textarea.value.substring(start, end);
   // This is the selected text and alert it
   alert(sel);
  var replace = '<b>' + sel + '<b>';
  // Here we are replacing the selected text with this one
 textarea.value =  textarea.value.substring(0,start) + replace + textarea.value.substring(end,len);
}

No comments: