1 / 49

Java Script

Java Script. Eng : SAHAR. Programming Language. HHL (High level language) لغات عالية المستوى LLL (Low level language) لغات منخفضة المستوى. Java Script is HLL. Usage of JavaScript. Creating a Programmable Web Page. Introduction to JavaScript.

Download Presentation

Java Script

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Script Eng : SAHAR

  2. Programming Language • HHL (High level language) • لغات عالية المستوى • LLL (Low level language) • لغات منخفضة المستوى Java Script is HLL

  3. Usage of JavaScript Creating a Programmable Web Page

  4. Introduction to JavaScript • JavaScript is an interpreted programming or script language from Netscape. • JavaScript is used in Web site development to such things as: • automatically change a formatted date on a Web page • cause a linked-to-page to appear in a popup window • cause text or a graphic image to change during a mouse rollover

  5. Writing a JavaScript Program • JavaScript programs can either be placed directly into the HTML file or they can be saved in external files. • The Web browser runs a JavaScript program when the Web page is first loaded, or in response to an event. • بيتم كتابة أكواد الجافا في أي مكان داخل كود HTML أي يمكن كتابتها في <Head> أو في <Body> • بيظهر أثر الكود في صفحة المتصفح

  6. How To Write Java Script In HTML • <HTML> • <head> • <Title>………. </title> Java Script Code • < /head > • <Body> • </ Body > • </HTML>

  7. OR • <HTML> • <head> • <Title>………. </title> • < /head > • <Body> Java Script Code • </ Body > • </HTML>

  8. Write Java Script Code • <Script> • </Script> • <Script Type = “text / JavaScript”> • </Script> • <Script Language =“JavaScript”> • </Script>

  9. Alert Code • بيستخدم لإظهار رساله تلقائيه للمستخدم حين فتحه للموقع • <Script> • Alert (“نص الرسالة”); • </ Script > • ; تستخدم لإنهاء السطر

  10. Save Project • لحفظ البرنامج بيتم الحفظ بإمتداد html و يتم ضبط encoding علي UTF-8وذلك لكي ندعم إستخدام كل اللغات بما فيهم اللغة العربيه • File save (name.html • utf-8)

  11. EX: • إظهار رسالة ” welcome“ للمستخدم عند بدإ فتح الصفحة • إظهار رسالة ” HIIIIII“ للمستخدم بعد إظهار رسالة ” Welcome“

  12. EX1 • <html> • <head> • <title>JavaScript </title> • </head> • <body> • <Script language = "JavaScript"> • alert ("welcome"); • </script> • </body> • </html>

  13. EX 2 • <html> • <head> • <title>JavaScript </title> • </head> • <body> • <Script language = "JavaScript"> • alert ("welcome"); • alert (“HIIIII"); • </script> • </body> • </html>

  14. Calculations • يوجد بلغات البرمجة أولويات للعمليات الحسابيه • و حيث أن العمليات الحسابيه هي + , - , * , / , ^ • لذلك نتبع إستخدام الأقواس لضبط العمليه الحسابية • الترتيب الذي تأخذه العمليات الحسابيه • الأسس ثم القسمه أو الضرب تم الجمع أو الطرح

  15. How To Use operation in Alert • <Script> • Alert ((5+15)*3); • </Script>

  16. OOP • البرمجه الشيئيه بتتكون من كائنات لها أحداث و يصاحبها أفعال (وظائف ) و لها خصائص • لغة الجافا سكربت من البرمجه الشيئيه لذلك فهي لها كل ما سبق

  17. Window .Alert • لأن alert هو الفعل المصاحب للكائن (Window) • AS : • <Script> • Window Alert (“Welcome”); • </Script>

  18. Others For Alert • Alert ( “ Welcome \n Ali”) • Alert ( “ Welcome \t Ali”) • \n تعني الكتابه في سطر جديد • \t تعني ترك مسافه

  19. Document . Write • للكتابه داخل الصفحة • Document. Write (“ النص المراد كتابته”) EXAMPLE ???????????

  20. Variables • A variable is a named element in a program that stores information. The following restrictions apply to variable names • المقصود بالمتغيرات هي حجز أماكن في زاكرة الجهاز • ففي لغة الجافا سكربت تعرف المتغیرات ب.( Var )

  21. Condition To Type Variable • لا يوجد بها مسافة • لا تستخدم العلامات الخاصه ك (# , ^ , & , * … etc) • تكتب كلها إما Capital أو Small و يفضل أن تكتب Small • لا يمكن التسميه باللغة العربيه • لا يمكن بدء الإسم برقم • لا تستخدم الكلمات المحجوزه

  22. الكلمات المحجوزه بالجافا breake case continue delete do else false for function if in new null return switch this true typeof var voide while with

  23. Variables • Var x ; • Var x = Num; • Var x = “ Name”; • EX : Var x = “ Welcome”; Var x = 5;

  24. Window. Confirm • تستخدم لإظهار رساله للمستخدم لكنها مختلفه عن رسالة Alert • Window. confirm (“Are You Sure??”) • بتظهر رساله فيها OK , Cancel

  25. Window. Prompt • تستخدم لإظهار رساله للمستخدم يمكنه الكتابه فيها • Window. prompt (“Your Name?"," Name”)

  26. EX: • نريد إظهار رسالة للمستخدم تسأله عن إسمه ثم بعد ذلك يرحب بإسم الشخص في الصفحة • //Var X ; • X = window prompt (“Your Name"," Name”); • Document . Write (“Welcome” +X)

  27. External Code • بيتم كتابة الكود خارج الصفحة ؤ يتم إستدعاؤه بها • <Script Src=MyCode .JS> • </Script> Note My Code External File Name JS Extention

  28. IF Statement • IF ( الشرط){ جواب الشرط } • EX حساب مجموع كلا من المتغيرين X,Y حيث X=10 Y = 20 و إظهر المجموع في رسالة

  29. Var x = 10; • Var y =20 ; • Var sum = 0; • IF sum ==0 { sum = x+ y; Window . Alert (“total is”+” ” + Sum); }

  30. IF Statement • IF ( الشرط){ جواب الشرط } Else IF ( الشرط){ جواب شرط أخر } Else ( الشرط){ جواب شرط أخر }

  31. EX: • Var x = 0 ; If (x==0){ Window. alert (“صفر”); } Else If (x > 0){ Window. alert (“رقم موجب ”); } Else If (x< 0){ Window. alert (“رقم سالب ”); }

  32. Else{ Window. alert (“ليس رقما ”); }

  33. Event • <Input type =“button” value = “ click “ On click = “ alert (‘you clicked me ‘)”> • يظهر Button عند الضغط عليه يعطي رسالة

  34. Function • Function msg () { Alert (“you clicked me ”) ; } • Input type “button” value = “ click “ On click =msg ();

  35. Switch Case • Switch ( ) { Case “ “ : Alert (“ ”); break ; Default : Alert ( “ ” ) }

  36. var country ; country=window. prompt( “ أدخل الدولة لتعرف عاصمتها "); switch ( country ) { Case ” مصر”: document. write(" عاصمتها القاهره") ; break ; Case “ العراق ” : document. write(" عاصمتها بغداد") ; break; Case “ السودان” : document. write("عاصمتها الخرطوم ") ; break ; default : document. write(" الدولة التي أدخلتها لیست من ضمن الخیارات المتاحة ") ; }

  37. Arrays • تستخدم لتعريف المتغيرات • فهي أشبه مايكون بالجدول حيث يمكننا تخزين متغير واحد في مجموعة من الخانات • يمكن أن تكون القيم رقميه او نصية • Var …… = new Array (“ .... “ , “….”, ”….” ) إسم المتغير عناصر المصفوفه

  38. EX: • <Script> • Var names = new Array (“ Ali “ , “Ahmed”, ”samy” ); • Alert (names[0]); • </Script>

  39. Another Method to Define Array • Var Names = new Array (); • Names [0] = “Ali”; • Names [1] = “Ahmed”; • Names [2] = “Samy”; • Names [3] = “Ramy”; • Alert ( Name[..] );

  40. Loops • FOR LOOP • For ( Initial value; condition; increment ){ • }

  41. EX : • <script> • for (i=0 ; i<10 ; i++) { • document.write("welcome <br />" ); • } • </script>

  42. While Loop • Var I = 0 ; • While (i<0) { • Document .write ( “ welcome <br />”); • i++ ; • }

  43. do …..while • Var i = 0 ; • do { • document .write ( “ welcome < br /> “); • i++ ; • } • while (i<10);

  44. String السلاسل النصيه EX : Var text = “how are you”; Document. write (text) Document. write (text. bold()); لجعل النص سميك

  45. Document. write (text. bold(). Strike()); لجعل النص سميك و مشطوب Document. write (text. font color (“red”)); لتغيير لون النص Document. write (text.toUpperCase ()); لجعل أحرف النص كبير Document. write (text.toLowerCase ()); لجعل أحرف النص صغيره

  46. Text . length • Document. write (text. length ) • تستخدم لتحديد طول النص المكتوب و هي Property وليست Method فلذلك لا يتبعها أقواس ()

  47. Index Of & Match • Index of  Position of The first letter of text • Match  the text

  48. EX: • Var text = “ How are you Ali ?“; • Document . Write (text. index of (“Ali”); • Document . Write (text. match of (“Ali”);

  49. What about ???? Document . Write (text. index of (“ali”); Or Document . Write (text. index of (“Ahmed”); Document . Write (text. match of (“ali”); Or Document . Write (text. match of (“Ahmed”);

More Related