Php basic learning notes (6)

Source: Internet
Author: User
Tags custom name
: This article mainly introduces php basic learning notes (6). If you are interested in the PHP Tutorial, refer to it. Window object

A window object is a "window object", that is, any open webpage. it must be "loaded" into a window object. The window object represents the window. Learning window objects is nothing more than learning the methods provided by window (similar to learning event objects is nothing more than learning the attributes of using event objects)

Window object pop-up dialog box methods:

1. window. alert ("here is text information"); // it can be considered as a text prompt. 2. var v1 = window. prompt ("text prompt", "default information") // A dialog box is displayed for users to enter text information. It is usually used to ask a user a question that requires text to answer. It returns a "string value" 3. var v2 = window. confirm ("a question about whether or not"); // A question is displayed asking the user about "True or false". The user can answer "true or false ". It is usually used to ask a user a question that requires "yes/no. It returns a boolean value (true/false ).

Window object pop-up window method:

Window. open (); -- a "small" window can be displayed, and a webpage can be placed in the window.

The syntax format is as follows:

Window. open ("url of the webpage to be opened", "name of the new window by yourself", and "para" for the appearance parameter of the new window ");

Url: it can be a relative address or an absolute address.

Name: Custom name, which can follow naming rules, such as n1, win1, s1

Para: There are several items in this setting. each item is separated by a comma. the format of each item is: item name = value. Example:

Width = 400, height = 300, left = 500, // indicates the distance from the left of the screen to top = 300, // indicates the distance from the top of the screen to menubar = yes; // indicates that the opened window has a menu bar (no), or you can use 1, 0 toolbar = yes; // indicates that the opened window has a toolbar (no ), you can also use 1, 0 location = yes; // to indicate that the opened window does not have the address bar (no), or you can use 1, 0 (the actual modern browser has expired, and the location must be displayed) scrollbars = yes; // indicates that the opened window has a scroll bar. ............. A comprehensive example of "Dhtml full manual": window. open ("http://www.baidu.com", "db", "width = 400, height = 300, left = 500, top = 300, menubar = yes, toolbar = 1 ") DHTML full manual. DHTML is "Dynamic html" (Dynamic HTML)

The timer method of the window object:

Timer: enables the browser to automatically perform certain tasks at regular intervals!

Syntax format:

Var t1 = window. setInterval ("code to be executed s", interval t); // This is called "Create a timer" and its name is t1.

Explanation: Code s in quotation marks will be executed at every specified time t. T is measured in milliseconds ". Here, the code to be executed usually uses a function call statement. The real thing to do is to complete it in the function.

Once a timer is created, it will automatically "allow others" to allow itself to either "survive" or "die"

How to find webpage objects

??? Document. getElementById ("id name"); // you can use the id to find a tag object for all tags in the id attribute. ? Document. getElementsByName ("name"); // The name attribute is usually used only on the form. Use name to find several tag objects, that is, a set. The set here is actually equivalent to a number of objects in an array. The usage of a set is exactly the same as that of an array. Note: Even if only one object is found in the result, it is also a set and should be used like an array .? Document. getElementsByTagName ("tag name"); obtain all the tag objects on the webpage through tag name-also a set. the usage is the same as above. Another more practical usage of getElementsByTagName is :?? Obj. getElementsByTagName ("tag name"); // obj is a smaller tag object. Get several objects with the specified tag name in the obj label -- more practical .? Document. body: -- indicates the specific tag object of the body in the webpage. Document.doc umentElement: -- directly represents the html tag object in the webpage. Document. images: -- indicates all img tag objects on the web page. it is also a set and its usage is the same as the preceding set. In fact, it is also equivalent to: document. getElementsByTagName ("img"); document. links: -- represents all a link tag objects in the webpage, and is also a set. Document. anchors: -- indicates all the-point tag objects on the webpage. Is it a set? Document. forms: -- represents all form objects in the webpage. it is also a set .? Event.tar get/event. srcElement: -- indicates the event source -- is the event source an object? This: -- indicates the event source -- it means that, like the window object, the event object, and the document object, are directly used instead of "finding.

Timer method of window object

Repetitive timer usage: The browser will repeatedly execute the code (function) at a specified interval ).

Var t1 = window. setInterval ("function ()", interval); // Create a recurring timer and name it "t1"

Window. clearInterval (t1) // clear (stop/destroy) this recurring timer

-- Alarm principle

One-time timer: The browser executes the code (function) once after the specified time ).

Var t2 = window. setTimeout ("function ()", interval); // create a one-time timer and name it "t2"

Window. clearTimeout (t2); // clear (stop/destroy) the one-time timer

-- Theory of time bomb

-- A one-time timer is usually used for some code that only needs to be executed once.

Embedded Framework (window)

Comparison frame window: The frame window divides the current large window into several small windows, each with a webpage.

        

Embedded window: it is a small window that is located in the "current webpage" and dug out a range of areas. this window can be placed on other webpages.

Here, the area dug out is actually the box concept in our html/css-the rectangular area.

The label of the embedded window is iframe, which uses the following:

Iframe looks very similar to a textarea tag, but its usage is completely different.

Iframe looks very similar to a textarea tag, but its usage is completely different.

Introduce external js files

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.