Home > Backend Development > PHP Tutorial > PHP basic study notes (6), PHP basic study notes_PHP tutorial

PHP basic study notes (6), PHP basic study notes_PHP tutorial

WBOY
Release: 2016-07-13 10:03:42
Original
802 people have browsed it

php basic study notes (6), php basic study notes

window object

The window object is the "window object", that is, any open web page must be "loaded" into a window object. The window object represents the window. Learning the window object is actually nothing more than learning several methods provided by the window (similar to learning the event object is nothing more than learning to use several attributes of the event object)

window Several methods for popping up dialog boxes:

<span>1</span><span>.    window.alert(&ldquo;这里是文字信息&rdquo;);            
</span><span>//</span><span>可以认为只是一个文字性提示信息。</span>
<span>2</span>.        <span>var</span>  v1  =<span>  window.prompt(&ldquo;文字提示&rdquo;,&ldquo;默认信息&rdquo;)    
</span><span>//</span><span>弹出一个供用户输入文字信息的对话框。通常用于向用户提出一个需要文字来回答的问题。其会返回一个&ldquo;字符串值&rdquo;</span>
<span>3</span>.        <span>var</span>  v2  =<span>  window.confirm(&ldquo;一个是否性的问题&rdquo;);        
</span><span>//</span><span>弹出一个向用户询问&ldquo;真假&rdquo;的问题,用户可以回答&ldquo;真假&rdquo;。通常用于向用户提出一个需要进行&ldquo;是/否&rdquo;性回答的问题。其会返回一个布尔值(true/false)。</span>
Copy after login

windowObject pop-up window method:

window.open();——You can pop up a "small" window, and you can "place" a web page in this window.

The grammatical form is as follows:

          window.open(“The web page address url to be opened”, “Name given to the new window by yourself”, “Appearance parameter setting para of the new window”);

URL: It can be a relative address or an absolute address.

name: Custom name, just follow the naming rules, such as n1, win1, s1

Para: This setting has several items, separated by commas. The format of each item is: item name = value. Examples are as follows:

width=<span>400</span><span>,
        height</span>=<span>300</span><span>,
        left</span>=<span>500</span>,        <span>//</span><span>表示离屏幕的左边的距离</span>
        top=<span>300</span>,        <span>//</span><span>表示离屏幕的顶部的距离</span>
        menubar = yes;    <span>//</span><span>表示打开的窗口具有菜单栏(no就没有),也可以使用1,0</span>
        toolbar    = yes;    <span>//</span><span>表示打开的窗口具有工具栏(no就没有),也可以使用1,0</span>
        location =  yes;    <span>//</span><span>表示打开的窗口没有地址栏(no就没有),也可以使用1,0(实际现代浏览器对此已经失效了,变成location必须显示)</span>
        scrollbars=yes;    <span>//</span><span>表示打开的窗口具有滚动条。</span>
<span>        &hellip;&hellip;&hellip;&hellip;. 查《Dhtml完全手册》
    综合举例:
window.open(&ldquo; http:</span><span>//</span><span>www.baidu.com&rdquo; , &ldquo;db&rdquo;, &ldquo;width=400, height=300, left=500,top=300, menubar=yes, toolbar=1&rdquo; ) </span>
<span>
《DHTML完全手册》介绍。 
DHTML就是&ldquo;动态html&rdquo;(Dynamic HTML) </span>
Copy after login

Timer method of window object:

Timer: refers to letting the browser automatically do certain things at certain intervals!

Grammar form:

var t1 = window.setInterval("code s to be executed", interval t); //This is called "creating a timer", the name is: t1

Explanation: Every set time t, the code s in quotation marks will be executed. The unit of t is "milliseconds". Here, the code to be executed usually uses a function call statement, and what really needs to be done is to complete it in the function.

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

Comprehensive methods to find web page partners

document.getElementById(&ldquo;id名&rdquo;);         <span>//</span><span>id属性所有标签都可以使用</span>
<span>    通过id找到一个标签对象。    
document.getElementsByName(&ldquo;name名&rdquo;); </span><span>//</span><span>name属性通常只用于表单上。</span>
<span>    通过name找到若干个标签对象&mdash;&mdash;也就是集合。这里集合其实就是相当于一个数组中放了若干个对象。集合的用法跟数组完全一样。注意,即使找出的结果中只有一个对象,也是集合,也要象数组一样使用。
document.getElementsByTagName(&ldquo;标签名&rdquo;);
    通过标签名获取到网页中所有的该标签对象&mdash;&mdash;也是集合,用法同上。
    getElementsByTagName的另一个更实用用法是:
    obj. getElementsByTagName(&ldquo;标签名&rdquo;);    </span><span>//</span><span>obj为某个小一点的标签对象。</span>
<span>    在obj这个标签中获取若干个指定标签名的对象&mdash;&mdash;更实用。

document.body:&mdash;&mdash;直接就代表网页中的body这个特定标签对象。
document.documentElement:&mdash;&mdash;直接就代表网页中的html这个特定的标签对象。

document.images:&mdash;&mdash;代表网页中的所有img标签对象,也是一个集合,用法同上述集合。其实其也相当于:document.getElementsByTagName(&ldquo;img&rdquo;);
document.links:&mdash;&mdash;代表网页中所有a链接标签对象,也是一个集合。
document.anchors:&mdash;&mdash;代表网页中的所有a锚点标签对象,也是一个集合
document.forms:&mdash;&mdash;代表网页中的所有form表单对象,也是一个集合。

</span><span>event</span>.target / <span>event</span><span>.srcElement:&mdash;&mdash;代表事件源&mdash;&mdash;事件源就是对象
</span><span>this</span><span>:&mdash;&mdash;代表事件源

&mdash;&mdash;意思是,象window对象,event对象,document对象是不需要&ldquo;找&rdquo;,而是直接使用。</span>
Copy after login

Timer method of window object

Use of recurring timer: The browser will execute the code (function) repeatedly at specified time intervals.

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

window.clearInterval(t1) //Clear (stop/destroy) the recurring timer

——Alarm clock principle

Use of one-time timer: The browser will execute 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

——Timing* principle

——One-time timer is usually used for some kind of code that only needs to be executed once

Inline frame (window)

Compare the frame window: The frame window divides the "current large window" into several small windows, and puts a web page in each window.

<frameset  rows=&rdquo;<span>150</span>, *&rdquo;>
        <frame src=&rdquo;page1.html&rdquo;  ></frame>
        <frame src=&rdquo;page2.html&rdquo;  ></frame>
</frameset>
Copy after login

Inline window: It is to "dig out" an area in the "current web page" as a small window, and this window can place other web pages.

Here, the "digging" area is actually the box concept in our HTML/CSS - a rectangular area.

The tag of the embedded window is: iframe, use as follows:

& lt; iframe src = "web address url" & gt; & lt;/iframe & gt;

iframe is very similar to the textarea tag in appearance, but its usage is completely different.

iframe is very similar to the textarea tag in appearance, but its usage is completely different.

Introduce external js files

                                                                                                                                                                                                                                          NOTE: The suffix of the js file is js. Moreover, there can be no more js code in the middle of the above script tag.

Principle of making progress bar

It is nothing more than two boxes. The width of the outer box is fixed (such as 100), and the width of the inner box changes with the change of a data - here is the current number of stars.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/967982.htmlTechArticlephp basic study notes (6), php basic study notes window object The window object is the window object, that is, any The opened web page must be loaded into a window object. ...
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template