PHP Basic Learning Notes JavaScript (5)

Source: Internet
Author: User

Special characters in the string:

In JS, double-quote content in double-quote strings and single quotation marks in single-quote strings must be transferred in the following form:

var str1 = "My mother say:\" don ' t speak with Stranger\ ". ";

var str2 = ' My mother say: ' don\ ' t speak with stranger '. ‘;

The commonly used escape characters in JS are:

"        ?    \ "'        ?    \ ' carriage return? \ r newline character?    \ntab    \t\        ? \ Note: Carriage return, line break, space and tab characters are actually also with a,b,c,d, and ', ',  $  & Wait for the symbol "equal juxtaposition".

Time Date Object:

The object used to represent the time date data. A time-date object includes specific information about the time and date, such as year, month, day, minute, millisecond, and week.

A time-date object is defined in the following ways:

D1 =NewDate ();//defines a Date object that represents the "current time".D2 =NewDate (" -/9/ -  One: -: +"); Use a string to define a date object for a specified time (moment) D3=NewDate ( -,9, -, One, -, +); Use multiple (at least 3) numbers to define a date object of a specified time D4=NewDate (2324624252312); A number is used to define a date object of a specified time.

This number represents the number of milliseconds that have elapsed since the start of the January 1, 1970 midnight 0:0 0 seconds (or even 0 millimeters). Note that one second is equal to 1000 milliseconds. In fact, we can understand that: "Time" this data, in JS, in fact, it is essentially just a number stored. If the value is negative, it indicates a forward projection. In fact, the time can be calculated by adding and subtraction.

This point in time is generally considered to be the "starting point/origin" of the computer world.

Common methods for TIME objects:

V1 =d1.tolocalestring (); Acquisition time is "local notation" v1=D1.gettime (); Get a "millimeter" of a time-starting from the time origin. The following is a data value in the Get time: v1= D1.getfullyear ();//get the number of years--is a number, the same asV1 = D1.getmonth ();//get the number of months-note: This number is calculated starting from 0, which can only be: 0-11V1 = D1.getdate ();//number of dates acquiredV1 = D1.getday ();//get the number of weeksV1 = d1.gethours ();//get the number of hoursV1 = D1.getminutes ();//get the number of minutesV1 = D1.getseconds ();//gets the number of secondsV1 = D1.getmilliseconds ();//get the number of milliseconds

The following are some of the data values in the setup time:

D1.setfullyear (n);        // Set the number of years D1 this time object to n-that is, the year is modified, the same as the same.     d1.setmonth (n  );        // sets the number of months D1. SetDate (n  );        // set the number of dates    D1. Setday (n  );        // set the number of weeks    D1. Sethours (n  );        // set number of hours    D1. Setminutes (n  );    // set the number of minutes    D1. Setseconds (n  );    // set number of seconds    D1. Setmilliseconds (n  );   Set the number of milliseconds
Introduction to Web Page objects

The first important idea: every tag in an HTML file is an object.

var obj1 = {                    name: "Floret", age                    :                    zuofan:functoin () {...},                    Xiyi: function () {...}}     var v1 = obj1.age;    Alert (v1);     ;    // Chinese New Year , added a year old--modified the Obj1 This object's age this property value.     obj1.name = "Big Flower";

How to get a page label object:

var obj1 = document.getElementById ("id name");

To manipulate the label properties of an object:

Get: var v1 = obj1. Tag property name;

Assignment: Obj1. Tag Property name = value;

Style properties for manipulating objects:

Get: var v1 = obj1.style. Style property name;--in fact, this way only gets its "inline style"

Assignment: Obj1.style. Style property name = value;

How to get a page label object:

var obj1 = document.getElementById ("id name");

To manipulate the label properties of an object:

Get: var v1 = obj1. Tag property name;

Assignment: Obj1. Tag Property name = value;

Style properties for manipulating objects:

Get: var v1 = obj1.style. Style property name;--in fact, this way only gets its "inline style"

Assignment: Obj1.style. Style property name = value;

Incident Preliminary

Simply put, the event is "action", that is, a user's operation, such as: Click, mouse movement, double-click, ...

First review and strengthen the "definition" JS: JS is an object-based event-driven scripting language.

What are the events:

    Mouse event:        onclick:         onmouseover:        onmouseout:        ondblclick:    Double-click event        onmousedown:      Mouse down when the time occurs (note that the mouse is not lifted up)        onmouseup:        the mouse lifted up when the        onmousemove: When the    mouse movement occurs-mobile everywhere.

Keyboard event:        onkeypress:    button click once occurs. OnKeyDown: onkeyup Occurs when the button is    pressed down        :        when the button is lifted up
Form event:        onsubmit    : Occurs    when a form is being "committed"        onfocus:        occurs when a form item "gets Focus".        onblur:        occurs when a form item "loses focus"        onchange: When the    data of a single table item changes--usually only for the Select label option Change.
Other:        onload:        occurs when the page "A load succeeds", that is, when the page opens,--onload can only appear once on a page. The  onload can only be written on the body tag, or it is not written in the label, but instead uses the solid line of window.onload in the script.

Summary: Events occur at any time and are ubiquitous, only in what event we want to use on which object to accomplish what work.

Its basic code pattern is:

    < tag name  ... On event name = "Function name F1 ();" >......</tag name >    <script>        function F1 () {            //  This is the job we're going to do!!!!!  }    </script>

The basic implication is that when something happens to an object, it calls a function to accomplish some sort of task.

Event Object

An event is an object within a browser (note, not a Web label object), which represents the collection of relevant information about the event when it occurs (the object is the collection of information)-it only exists when the event occurs!

An event is typically used only to obtain information about the time the event occurred, such as the coordinates of the mouse at that moment (x and Y), which page object was the event, which mouse button was triggered when the event occurred, or which key on the keyboard. The above information is obtained by the following event properties:

event.clientx--gets the x-coordinate position of the mouse when the event occurs

event.clienty--Gets the y-coordinate position of the mouse when the event occurs

event.target--Gets the tag object (for FF) when the event occurs--similar to the getElementById acquired object

event.srcelement--gets the tag object when the event occurred (for IE)-similar to the getElementById acquired object

-the Label object at the time of the event is often referred to as the "event source."

event.keycode--the key value of the key when the keyboard event occurs--each key on the keyboard corresponds to a numeric value.

comparison of this and event usage:< label name 1 on event name = "Function name F1 ( This) "> ..... </Tag name 1> < label name 2 on event name = "Function name F2 (Event) "> ..... </Tag name 2> <script>function F1 (obj) {//In this range, obj represents the object "label name 1", similar to the object obtained using getElementById}function F2 (evt) {//In this scope, the EVT represents the event object at the time the incident occurred. //using evt here is basically using its following attributes (as needed):            varV1 = Evt.clientx;//get the x-coordinate of the mouse at the time            varv2 = Evt.clienty;//get the Y coordinate of the mouse at the time            varV3 = Evt.keycode;//get keyboard key values (only valid for keyboard events)            varV4 = Evt.target;//get the event source object, IE is: evt.srcelement;}    </script>

PHP Basic Learning Notes JavaScript (5)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.