zoukankan      html  css  js  c++  java
  • 学习Web开发写的第一个js脚本

    刚接触Web开发,好几天了不知道从哪里下手,仔细想了一下原因大概如下:

    1)、不了解web应用运行的详细模型和流程,就是原理问题。

    2)、一时没分清楚网页和web应用的关系,比如用ASP.net时分不清楚是么时候用HTML标记,什么时候用web control。

    3)、其实写代码倒不是问题,Web开发有一些有别于WinForm开发的特殊对象和编程规范。像session,cookie,response,document等。

    感觉要能有质的突破,需要深刻理解以上关键点。

    今早手工编写了第一个HTML脚本,建立起基本概念。

    <HTML>     <head>         <script language="javascript">             //改变网页内容             function changeContent(document,num)             {              if(num==1)              {                  for(i=1;i<100;i++)                  {                     document.write(i+"<br>");                  }                               document.bgColor = "red";                                    }              if(num==2)              {                     for(i=1;i<100;i++)                     {                      document.write(100-i+"<br>");                     }                                     document.bgColor = "yellow";              }                          }                   //-------------------------------------------------------------------------             //弹出窗口             function popWindow()             {              pop_win=open("http://www.sohu.com","sohu","top=100,left=100,width=100,height=100");              return str;             }                      //-------------------------------------------------------------------------                         //状态栏滚动文字介绍             //自左向右,循环滚动             function Helpor_net(seed)             {                 var m1 = "你要显示的文字,如:欢迎来到晓寒工作室" ;                 var m2 = "" ;                 var msg=m1+m2;                 var out = " ";                 var c = 1;                 var speed = 120;                 if (seed > 100)                 {                     seed-=2;                     var cmd="Helpor_net(" + seed + ")";                     timerTwo=window.setTimeout(cmd,speed);                 }                 else if (seed <= 100 && seed > 0)                 {                     for (c=0 ; c < seed ; c++)                     { out+=" ";}                     out+=msg;                     seed-=2;                     var cmd="Helpor_net(" + seed + ")";                     window.status=out;                     timerTwo=window.setTimeout(cmd,speed);                 }                 else if (seed <= 0)                 {                     if (-seed < msg.length)                     {                         out+=msg.substring(-seed,msg.length);                         seed-=2;                         var cmd="Helpor_net(" + seed + ")";                         window.status=out;                         timerTwo=window.setTimeout(cmd,speed);                     }                     else                     {                         window.status=" ";                         timerTwo=window.setTimeout("Helpor_net(100)",speed);                     }                 }             }             Helpor_net(100);         </script>     </head>      <body>     <center>             <div><input type=button value=按钮1 onclick=changeContent(document,1);></div>         <div><input type=text value=text1 onselect=alert("text1");></div>         <div><input type=text value=text2 onfocus=alert("text2");></div>         <div>         <select type=select name=combobox onChange=comboxChanging();>             <option value=a>111</option>             <option value=b>222</option>             <option selected value=c>333</option>                     </select>         </div>     </enter>          <br>          <div>         <input type=button value=按钮2 onclick="f2(document,2);">     </div>              <div>         <input type=button value=弹出窗口 onclick="pop_window=popWindow();">         <br>         <input type=button value=关闭窗口 onclick="pop_window.close();">     </div>              <script>         function comboxChanging()         {             alert("你选择了"+combobox.value);         }     </script>      </body> </html>

  • 相关阅读:
    PAT (Advanced Level) 1114. Family Property (25)
    PAT (Advanced Level) 1113. Integer Set Partition (25)
    PAT (Advanced Level) 1112. Stucked Keyboard (20)
    PAT (Advanced Level) 1111. Online Map (30)
    PAT (Advanced Level) 1110. Complete Binary Tree (25)
    PAT (Advanced Level) 1109. Group Photo (25)
    PAT (Advanced Level) 1108. Finding Average (20)
    PAT (Advanced Level) 1107. Social Clusters (30)
    PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)
    PAT (Advanced Level) 1105. Spiral Matrix (25)
  • 原文地址:https://www.cnblogs.com/flyingfish/p/683946.html
Copyright © 2011-2022 走看看