PHP basic study notes (6)

WBOY
Release: 2016-08-08 09:28:14
Original
941 people have browsed it

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 (similarly, learning the event object is nothing more than learning to use several attributes of the event object)

window Several pop-up dialog box methods:

<span>1</span><span>.    window.alert(“这里是文字信息”);            
</span><span>//</span><span>可以认为只是一个文字性提示信息。</span>
<span>2</span>.        <span>var</span>  v1  =<span>  window.prompt(“文字提示”,“默认信息”)    
</span><span>//</span><span>弹出一个供用户输入文字信息的对话框。通常用于向用户提出一个需要文字来回答的问题。其会返回一个“字符串值”</span>
<span>3</span>.        <span>var</span>  v2  =<span>  window.confirm(“一个是否性的问题”);        
</span><span>//</span><span>弹出一个向用户询问“真假”的问题,用户可以回答“真假”。通常用于向用户提出一个需要进行“是/否”性回答的问题。其会返回一个布尔值(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, each item is separated by a comma, and 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>        …………. 查《Dhtml完全手册》
    综合举例:
window.open(“ http:</span><span>//</span><span>www.baidu.com” , “db”, “width=400, height=300, left=500,top=300, menubar=yes, toolbar=1” ) </span>
<span>
《DHTML完全手册》介绍。 
DHTML就是“动态html”(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 the 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(“id名”);         <span>//</span><span>id属性所有标签都可以使用</span>
<span>    通过id找到一个标签对象。    
?document.getElementsByName(“name名”); </span><span>//</span><span>name属性通常只用于表单上。</span>
<span>    通过name找到若干个标签对象——也就是集合。这里集合其实就是相当于一个数组中放了若干个对象。集合的用法跟数组完全一样。注意,即使找出的结果中只有一个对象,也是集合,也要象数组一样使用。
?document.getElementsByTagName(“标签名”);
    通过标签名获取到网页中所有的该标签对象——也是集合,用法同上。
    getElementsByTagName的另一个更实用用法是:
    ??obj. getElementsByTagName(“标签名”);    </span><span>//</span><span>obj为某个小一点的标签对象。</span>
<span>    在obj这个标签中获取若干个指定标签名的对象——更实用。

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

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

?</span><span>event</span>.target / <span>event</span><span>.srcElement:——代表事件源——事件源就是对象
?</span><span>this</span><span>:——代表事件源

——意思是,象window对象,event对象,document对象是不需要“找”,而是直接使用。</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"

C Window.Clearinterval (T1) // Clear (stop/destroy) this repetitive 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

——Time bomb principle

   —One-time timers are 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, which can place other web pages.

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

The label of the inline window is: iframe, use as follows:

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

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

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

Introduce external js files

                                                                                                                                                                                          NOTE: The suffix of the js file is js. It can only contain js syntax code, and cannot have

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template