110 likes | 135 Views
Programming in Jscript.NET. Masatoshi Natsume. Jscript. Script language developed by Microsoft Compatible with JavaScript Netscape Communication Sun Microsystems Extensions File operation Component Object Module (COM) Embedded in HTML. Jscript.NET. Current version of Jscript
E N D
Programming in Jscript.NET Masatoshi Natsume
Jscript • Script language developed by Microsoft • Compatible with JavaScript • Netscape Communication • Sun Microsystems • Extensions • File operation • Component Object Module (COM) • Embedded in HTML
Jscript.NET • Current version of Jscript • Compatible with Jscript • Supports .NET framework • Jscript.NET needs to be compiled • Jscript.NET has higher performance
Declare Jscript <html> <head> <title>Sample</title> </head> <body> <script language=”Jscript”> [Program code] </script> </body> </html>
Hello World!! <script language=”Jscript”> dd = new Date(); document.write(dd.toLocaleString()); document.write("<br>"); document.write("Hello World!!"); </script> View in browser
Loading Script File • <script language="Jscript" src="function.js">
Text Field <html> <head> <title>Text Filed</title> <script Language="Jscript"> function check() { txt = document.myFORM.myTEXT.value; if (txt == ""){ alert("Text field is empty"); }else{ alert("Entered: " + txt) } } </script> </head> <body> <form name="myFORM"> <input type="text" name="myTEXT"> <input type="button" onClick="check()" value="Check"> </form> </body> </html> View in Browser
Radio Button <html> <head> <title>Radio Button</title> <script language="Jscript"> var msg; function rdo_Change(obj){ msg = obj.value; } function func3(obj){ alert("My favorite fruit is " + msg); } </script> <form name=frm3> Please select your favorite fruits<br><br> <input type="radio" name="rdo1" value="Apple" onClick=rdo_Change(this)>Apple<br> <input type="radio" name="rdo1" value="Banana" onClick=rdo_Change(this)>Banana<br> <input type="radio" name="rdo1" value="Pineapple" onClick=rdo_Change(this)>Pineapple<br> <input type="radio" name="rdo1" value="Orange" onClick=rdo_Change(this)>Orange<br><br> <input type="button" value="Check" onDblClick=func3(rdo1)><br> </form> </body> </html> View in Browser
Check Box <html> <head> <title>Check BOx</title> <script language="Jscript"> function func5(){ var cnt=0; var i; for (i =0; i< document.frm5.elements.length;i++){ if(document.frm5.elements[i].checked) cnt++; } alert (cnt + " CheckBoxes are selected" + "\n" + "CheckBox1 checked: " + document.frm5.elements[0].checked + "\n" + "CheckBox2 checked: " + document.frm5.elements[1].checked + "\n" + "CheckBox3 checked: " + document.frm5.elements[2].checked + "\n" + "CheckBox4 checked: " + document.frm5.elements[3].checked); } </script> <form name=frm5> <input type=checkbox name=chk1>Check1<br> <input type=checkbox name=chk2>Check2<br> <input type=checkbox name=chk3>Check3<br> <input type=checkbox name=chk4>Check4<br><br> <input type=button value="Check" onClick=func5()> </form> </body> </html> View in Browser
Conclusion • Jscript.NET is an easy language like VB.NET • The compatibility with JavaScript is not perfect • Jscript.NET has attractive features.