global variable

Minggu, 15 April 2012

Windows Muter² With JavaScript (Part 1)

·

 

HTML <script> Tag

The <script> tag is used to define a client-side script, such as a JavaScript.
<script type="text/javascript">

Window scrollBy() Method

The scrollBy() method scrolls the content by the specified number of pixels.
window.scrollBy(0, 1);

Window resizeTo() Method

The resizeTo() method resizes a window to the specified width and height.
window.resizeTo(0,0);

Window moveTo() Method

The moveTo() method moves a window's left and top edge to the specified coordinates.
window.moveTo(0,0);

Window setTimeout() Method

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
setTimeout("move()", 1);

JavaScript Variables

You can declare JavaScript variables with the var keyword.
var mxm=50
var mym=25
var mx=0
var my=0
var sv=50
var status=1
var szx=0
var szy=0
var c=255
var n=0
var sm=30
var cycle=2
var done=2

JavaScript Functions

A function contains code that will be executed by an event or by a call to the function.
function move()

JavaScript If...Else Statements

Use the if statement to execute some code only if a specified condition is true.
Use the if....else statement to execute some code if a condition is true and another code if the condition is not true.
Use the if....else if...else statement to select one of several blocks of code to be executed.
{
  if (status == 1)
  {
    mxm=mxm/1.05
    mym=mym/1.05
    mx=mx+mxm
    my=my-mym
    mxm=mxm+(400-mx)/100
    mym=mym-(300-my)/100

    window.moveTo(mx,my)

JavaScript Math Object

The Math object allows you to perform mathematical tasks.

JavaScript round() Method

The round() method rounds a number to the nearest integer.
rmxm=Math.round(mxm/10)
    rmym=Math.round(mym/10)

    if (rmxm == 0)
    {
      if (rmym == 0)
      {
        status=2
      }
    }
  } //end of if (status == 1)

  if (status == 2)
  {
    sv=sv/1.1
    scrratio=1+1/3
    mx=mx-sv*scrratio/2
    my=my-sv/2
    szx=szx+sv*scrratio
    szy=szy+sv

    window.moveTo(mx,my)
    window.resizeTo(szx,szy)

    if (sv < 0.1)
    {
      status=3
    }
  } //end of if (status == 2)

  if (status == 3)
  {
    document.fgColor=0xffffFF
    c=c-16

    if (c < 0)
    {
      status=8
    }
  } //end of if (status == 3)

  if (status == 4)
  {
    c=c+16
    document.bgColor=c*65536
    document.fgColor=(255-c)*65536

    if (c > 239)
    {
      status=5
    }
  } //end of if (status == 4)

  if (status == 5)
  {
    c=c-16
    document.bgColor=c*65536
    document.fgColor=(255-c)*65536

    if (c < 0)
    {
      status=6
      cycle=cycle-1

      if (cycle > 0)
      {
        if (done == 1)
        {
          status=7
        }
        else
        {
          status=4
        }
      }
    }
  } //end of if (status == 5)

  if (status == 6)
  {
    document.title = "Cljck"
    alert("Cljck")
    cycle=2
    status=4
    done=1
  } //end of if (status == 6)

  if (status == 7)
  {
    c=c+4
    document.bgColor=c*65536
    document.fgColor=(255-c)*65536

    if (c > 128)
    {
      status=8
    }
  } //end of if (status == 7)

  if (status == 8)
  {
    window.moveTo(0,0)
    sx=screen.availWidth
    sy=screen.availHeight
    window.resizeTo(sx,sy)
    status=9
  } //end of if (status == 8)

  var timer=setTimeout("move()",0.3)
}
</script>
 
 
 
full script


 

Tidak ada komentar:

Posting Komentar

handapeunpost