Free Essay

Info262

In:

Submitted By grey3544
Words 685
Pages 3
1. The syntax of the do while statement in JavaScript is as follows:

do statement while (condition);

The do while statement is used when one requires a loop to execute at least once before the condition is met, such as performing a calculation.

2. Images placed in an Array can be accessed using the documents.images[0-x] statement. The documents.images portion of the statement utilizes the document object and the sub object images, and the [0-x] portion refers to the specific image that has been placed into an array, ranging from 0 to how many members of the array exist (represented by x). You can also refer to images via their name attribute as follows: <img name=”image1” src=”image.jpg” />. 3. The JavaScript substring method will pull the letters “Scr” from spaces 4-6, using:
“JavaScript”.substring(4, 6);
Then the length method will return the length of the String in quotations as follows: “JavaScript”.length;
Lastly, the charAt method returns the character at a specified index inside the string as such: “JavaScript”.charAt(4);

4. The date object is created using the syntax var d = new Date(day, month, years, hours, etc.);. In order to use it, you use the get method to pull the relevant information from the computer. Three methods of particular use are the getDate() method, which pulls the day of the month from the computer, the getDay() method, which pulls the day of the week in numerical format ranging from 0-6, and the getMonth() method, which returns the month ranging from 0-11. 5.
One can output the names and values of a form’s fields using the document.formName.defaultText.value; syntax, as follows:

<form name="myForm" >
<input type="text" name="firstName" >
</form>
document.myForm.firstName.value;

6. Forms are the primary means of gathering information from users. Three main methods of doing this are the radio button, the check box, and the text box. The radio button allows a single choice to be made. Check boxes allow the user to select multiple values. Text boxes allow the user to enter information in any valid form via the keyboard.
The JavaScript for buttons is : <input type=”button” value=”action” onClick=”function();”>
The JavaScript for check boxes is <input type="checkbox" name="myCheckbox">
Lastly, the JavaScript for text boxes is <input type="text" name="myText">

7. One can search for a cookie’s presence using the (alert(document.cookie);) method, which tests for the presence of a specific cookie and alerts the user as to its presence.

8. JavaScript is a powerful tool that allows servers to communicate with user’s computers. However, because it allows access to stored information about the user, it can be used in a malicious manner. While there are several security issues with JavaScript, Cross-Server Scripting is a primary problem for users. This occurs when a person is redirected from a site they trust to a site that could potentially steal their information such as their username, passwords, or other sensitive information. In addition, information from cookies can be stolen and utilized for the same purposes. 9.
First, one would use HTML to create a button on the form or website.

<form><input type=”button” value=”Switch to another frame” onClick=”changeFrames();”></form> And then the developer would use the following JavaScript in conjunction with the previous html:
<script > function changeFrames() { parent.rightTop.location.href=”home.htm”; parent.rightBottom.location.href=”faq.htm”; } </script >

10. The constructor property refers to the function that creates the object. This means that despite the fact that the object has not been instantiated yet, once it is, it can refer to the specific set of variables mentioned in the constructor. For example, if you were to instantiate variables length, width, and height with values of 10 each, you could later create a box object that refers to those dimensions and then utilizes them in calculating the volume of the box (1000).

Similar Documents