Feeds:
Tulisan
Komentar

Try it !!!

<HTML>
 <HEAD>
  <title>Cool Mouse Trail</title>
  <style>
  .spanstyle
  {
   COLOR: black;
   FONT-FAMILY: Verdana;
   FONT-SIZE: 8pt;
   FONT-WEIGHT: bold;
   POSITION: absolute;
   TOP: -50px;
   VISIBILITY: visible
  }
  </style>

  <SCRIPT LANGUAGE=”JavaScript”>
  <!– Begin
  var x, y;
  var step = 10;
  var flag = 0;

  var message = “Iin Dewi Wahyuni !!!”;
  message = message.split(”");
  var xpos = new Array();
  for (i = 0; i <= message.length – 1; i++)
  {
   xpos[i] = -50;
  }
  var ypos = new Array();
  for (i = 0; i <= message.length – 1; i++)
  {
   ypos[i]= -50;
  }
  
  function handlerMM(e)
  {
   x = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX;
   y = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY;
   flag = 1;
  }
  
  function makesnake()
  {
   //alert(’ok’);
   if (flag == 1 && document.all)
   {
    for (i = message.length – 1; i >= 1; i–)
    {
     xpos[i] = xpos[i - 1] + step;
     ypos[i] = ypos[i - 1];
    }
   
    xpos[0] = x + step;
    ypos[0] = y;
    for (i = 0; i < message.length – 1; i++)
    {
     var thisspan = eval(”span” + (i) + “.style”);
     thisspan.posLeft = xpos[i];
     thisspan.posTop = ypos[i];
    }
   }
   else if (flag==1 && document.layers)
   {
    for (i = message.length – 1; i >= 1; i–)
    {
     xpos[i] = xpos[i - 1] + step;
     ypos[i] = ypos[i - 1];
    }
    xpos[0] = x + step;
    ypos[0] = y;
    for (i = 0; i < message.length – 1; i++)
    {
     var thisspan = eval(”document.span” + i);
     thisspan.left = xpos[i];
     thisspan.top = ypos[i];
    }
   }
   var timer = setTimeout(”makesnake()”, 10);
  }
  // End –>
  </script>
 </HEAD>

 <body style=”OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%” onLoad=”makesnake();”>
  <SCRIPT LANGUAGE=”JavaScript”>
  <!– Begin
  for (i = 0; i <= message.length-1; i++)
  {
   document.write(”<span id=’span”+i+”‘ class=’spanstyle’>”);
   document.write(message[i]);
   document.write(”</span>”);
  }
  if (document.layers)
  {
   document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = handlerMM;
  // End –>
  </script>
 </body>
</HTML>

Ajax is stand for Asynchronous Javascript and XML.
The question is what kind of javascript’s object that has been use for making Ajax object ? as we know that outside, there is a lot of Ajax object that has been made. Like MagicAjax, Atlas, etc.
The answer is HttpObject in javascript. The existing HttpObject until now is XMLHttpRequest, “MSXML2.XMLHTTP” activeXobject, “Microsoft.XMLHTTP” activeXobject.

Example :

function GetHttpObject()
{
  var xmlhttp;
 
   if (window.XMLHttpRequest)
 {
  try{xmlhttp = new XMLHttpRequest();}
  catch (e){ xmlhttp = false;}
 }
 else if (window.ActiveXObject)
 {
  var clsids = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
  for(var i=0; i<clsids.length; i++)
  {
   try{xmlhttp = new ActiveXObject(clsids[i]);break;}
   catch (e){xmlhttp = false;}
  }
 }
  return xmlhttp;
}

Two Mode Currency Format is a format that has two mode, 1. Replace mode s a mode that has fixed format (masking) which is the character will replaced by character of keystroke. So the value will not increase.2. Non replace mode is a mode that will put the pointer in a fixed position so when we enter the character so the value of the TextBox will increase. I’m using createRange function in javascript to make this kind of format. createRange is a function/class that will make one or more cursor selection in a document. When we call select() function then automatically cursor will select the character from the first position of cursor until the end of cursor selection which is set when we call moveEnd function.

Example :

var docrng = document.selection.createRange();
docrng.collapse();
docrng.moveStart(’character’, 0);
docrng.moveEnd(’character’, 1);
docrng.select();

As you see in the example above that we make the instance of document createRange and then we call collapse() function to make the selection is collapse, then we set first position the cursor selection by calling moveStart function and last position of cursor selection by calling moveEnd function. That is the basic function that I have been use to make this Two Mode Currency Format, to see the whole source code you can download it (SourceCode.zip).

First we described which character that allow to enter in TextBox (_allowChar). We put the e.keyCode which is represent the keystroke in a variable _keycode, then we put the unescape of keystroke in a variable char, then we will find the keystroke character in a variable _allowChar using indexOf functionality. We check is it the character exist or not. indexOf function will find the proper character from the string variable which is called this function, if doesn’t exist then indexOf will return -1 (integer) and if there is exist then indexOf will return 0. You can see the whole function below this.

function NumericValidation(e)
{
 var _allowChar = “0123456789″ + unescape(’%’ + (8).toString(16));
 var _keycode = e.keyCode;
 var char = unescape(’%’ + _keycode.toString(16));
 return (_allowChar.indexOf(char)!=-1);
}
This is the sample of how we use NumericValidation function. This function will call in OnKeyPress event in a TextBox.

<HTML>
 <HEAD>
  <title>Numeric</title>
  <script language=”javascript”>
function NumericValidation(e)
{
 var _allowChar = “0123456789″ + unescape(’%’ + (8).toString(16));
 var _keycode = e.keyCode;
 var char = unescape(’%’ + _keycode.toString(16));
 return (_allowChar.indexOf(char)!=-1);
}
</script>
 </HEAD>
 <body>
  <form id=”Form1″ method=”post”>
  <input type=”text” name=”Text1″ onkeypress=”NumericValidation(event)”>
  </form>
 </body>
</HTML>

We create new Resource file in a current project and then we add the textfile that already we fill with some data to Resource file. So that we ready to use it.

This is the sample code :

protected void Form1_Load(object sender, System.EventArgs e)
{
               Assembly assem = Assembly.GetExecutingAssembly();
               string value = Resource.TextFile; // TextFile is the name of resource object (textfile that we add)
}

Tulisan Sebelumnya »