Programming in Jscript NET Masatoshi Natsume Jscript Script

  • Slides: 11
Download presentation
Programming in Jscript. NET Masatoshi Natsume

Programming in Jscript. NET Masatoshi Natsume

Jscript • Script language developed by Microsoft • Compatible with Java. Script – Netscape

Jscript • Script language developed by Microsoft • Compatible with Java. Script – 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

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>

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. to. Locale. String()); document.

Hello World!! <script language=”Jscript”> dd = new Date(); document. write(dd. to. Locale. String()); document. write(" "); document. write("Hello World!!"); </script> View in browser

Loading Script File • <script language="Jscript" src='data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%20415%20289%22%3E%3C/svg%3E' data-src="function. js">

Loading Script File • <script language="Jscript" src="function. js">

Text Field <html> <head> <title>Text Filed</title> <script Language="Jscript"> function check() { txt = document.

Text Field <html> <head> <title>Text Filed</title> <script Language="Jscript"> function check() { txt = document. my. FORM. my. TEXT. value; if (txt == ""){ alert("Text field is empty"); }else{ alert("Entered: " + txt) } } </script> </head> <body> <form name="my. FORM"> <input type="text" name="my. TEXT"> <input type="button" on. Click="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 =

Radio Button <html> <head> <title>Radio Button</title> <script language="Jscript"> var msg; function rdo_Change(obj){ msg = obj. value; } function func 3(obj){ alert("My favorite fruit is " + msg); } </script> <form name=frm 3> Please select your favorite fruits <input type="radio" name="rdo 1" value="Apple" on. Click=rdo_Change(this)>Apple <input type="radio" name="rdo 1" value="Banana" on. Click=rdo_Change(this)>Banana <input type="radio" name="rdo 1" value="Pineapple" on. Click=rdo_Change(this)>Pineapple <input type="radio" name="rdo 1" value="Orange" on. Click=rdo_Change(this)>Orange <input type="button" value="Check" on. Dbl. Click=func 3(rdo 1)> </form> </body> </html> View in Browser

Check Box <html> <head> <title>Check BOx</title> <script language="Jscript"> function func 5(){ var cnt=0; var

Check Box <html> <head> <title>Check BOx</title> <script language="Jscript"> function func 5(){ var cnt=0; var i; for (i =0; i< document. frm 5. elements. length; i++){ if(document. frm 5. elements[i]. checked) cnt++; } alert (cnt + " Check. Boxes are selected" + "n" + "Check. Box 1 checked: " + document. frm 5. elements[0]. checked + "n" + "Check. Box 2 checked: " + document. frm 5. elements[1]. checked + "n" + "Check. Box 3 checked: " + document. frm 5. elements[2]. checked + "n" + "Check. Box 4 checked: " + document. frm 5. elements[3]. checked); } </script> <form name=frm 5> <input type=checkbox name=chk 1>Check 1 <input type=checkbox name=chk 2>Check 2 <input type=checkbox name=chk 3>Check 3 <input type=checkbox name=chk 4>Check 4 <input type=button value="Check" on. Click=func 5()> </form> </body> </html> View in Browser

Conclusion • Jscript. NET is an easy language like VB. NET • The compatibility

Conclusion • Jscript. NET is an easy language like VB. NET • The compatibility with Java. Script is not perfect • Jscript. NET has attractive features.

QUESTIONS?

QUESTIONS?