{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AhmedsJSPart2 - 1 2 3 4 5 6 7 8 2.2 Immediate Scripts In...

Info icon This preview shows pages 1–26. Sign up to view the full content.

View Full Document Right Arrow Icon
1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2
Image of page 2
3
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4
Image of page 4
5
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6
Image of page 6
7
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
8
Image of page 8
2.2: Immediate Scripts: In some of our examples, we have placed JavaScript codes in the event attribute’s values. This code will not be executed unless the respective events happen. Initially when the browser displays the page, it goes through every line of your HTML code and resolves the <tags> (that means it displays the contents of the tags). However, it ignores the instructions specified in the event attributes (unless the event happens). 9
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
In addition to inserting codes in an event attribute, we can simply insert JavaScript code in the <body> of an HTML document (of course within the <script></script> tags). These scripts are often called Immediate Scripts. In commercial Web Pages, the Immediate Scripts may not p lay a great role, but these are extremely useful for learning and to practice JavaScript syntax. Remember, the Immediate Scripts are simply JavaScript codes inside <script> tags in the <body> section. Here is an example: 10
Image of page 10
11
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
In the above code, observe that the <script> tag has been included inside the <body> element just like any other HTML tag (such as <p>, <div>, <table> etc.) When the browser loads the document into a Web page, it will simply go in sequence and treat the <script> tag exactly like any other HTML tag. Thus it will execute the JavaScript instruction when it comes to the <script> tag. It will not wait for any event to occur. 12
Image of page 12
13
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
14
Image of page 14
15
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
16
Image of page 16
Example of JavaScript alert (We have already discussed the alert). Anyway, we will give an example here again. 17
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
18
Image of page 18
alert1.htm 19
Image of page 19

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
20
Image of page 20
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern