120 likes | 245 Views
Client-Side Scripts. เอกสารประกอบการบรรยายรายวิชา 204200 Browser-Based Application Development. วัตถุประสงค์. นักศึกษาสามารถอธิบายแนวคิดเกี่ยวกับ Client-Side Scripts นักศึกษาสามารถประยุกต์ใช้ Client-Side Scripts. หัวข้อบรรยาย. Hello World! Validation Link Rollover Image Rollover.
E N D
Client-Side Scripts เอกสารประกอบการบรรยายรายวิชา204200Browser-Based Application Development
วัตถุประสงค์ • นักศึกษาสามารถอธิบายแนวคิดเกี่ยวกับ Client-Side Scripts • นักศึกษาสามารถประยุกต์ใช้ Client-Side Scripts
หัวข้อบรรยาย • Hello World! • Validation • Link Rollover • Image Rollover
Hello World! <script language="javascript"> alert("Hello World!"); function HiJa() { alert("Hi Ja"); } </script> </head> <body MS_POSITIONING="GridLayout"> <a href="http://www.sut.ac.th/" onmouseover=HiJa()>Click Here</a> </body>
Validation <script language="javascript"> function validateForm(form) { if(form.firstname.value=="") { alert("Please input firstname."); return false; } return true; } </script> <form id="Form1" method="post" onsubmit="return validateForm(this);"> <INPUT name="firstname" type="text"> <INPUT type="submit" value="Submit"> <DIV ms_positioning="FlowLayout">First Name</DIV> </form>
Link Rollover We are SUT! Chula IBM Monk.com
Link Rollover <script> function highlight(which,color){ if (document.all||document.getElementById) which.style.backgroundColor=color } </script> <p><a href="http://www.sut.ac.th/" onMouseover="highlight(this,'orange')" onMouseout="highlight(this,document.bgColor)"> We are SUT! </a> <p><a href="http://www.chula.ac.th/" onMouseover="highlight(this,'pink')" onMouseout="highlight(this,document.bgColor)"> Chula </a> <p><a href="http://www.ibm.com/" onMouseover="highlight(this,'lightblue')" onMouseout="highlight(this,document.bgColor)"> IBM </a> <p><a href="http://www.monk.com/" onMouseover="highlight(this,'yellow')" onMouseout="highlight(this,document.bgColor)"> Monk.com </a>
Link Rollover <script> function highlight(which,color){ if (document.all||document.getElementById) which.style.backgroundColor=color } </script> <p><a href="http://www.sut.ac.th/" onMouseover="highlight(this,'orange')" onMouseout="highlight(this,document.bgColor)"> We are SUT! </a> <p><a href="http://www.chula.ac.th/" onMouseover="highlight(this,'pink')" onMouseout="highlight(this,document.bgColor)"> Chula </a> <p><a href="http://www.ibm.com/" onMouseover="highlight(this,'lightblue')" onMouseout="highlight(this,document.bgColor)"> IBM </a> <p><a href="http://www.monk.com/" onMouseover="highlight(this,'yellow')" onMouseout="highlight(this,document.bgColor)"> Monk.com </a>
Image Rollover <script language="Javascript"> <!-- if (document.images) { button1 = new Image button2 = new Image button1.src = "img1.gif" button2.src = "img2.gif" } //--> </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> </form> <a href="http://test.net" onmouseover="document.rollover.src=button2.src" onmouseout="document.rollover.src=button1.src"> <img src="img1.gif" border="0" name="rollover"></a> </body>
E-mail • Reference http://www.java-scripts.net http://www.javascripts.com