国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 語言 > JavaScript > 正文

深入學(xué)習(xí)JavaScript中的bom

2024-05-06 15:38:53
字體:
供稿:網(wǎng)友

BOM(Broswer Object Model)

凡是 window 的屬性和方法,均可以省略“window.”

方法:

框窗

1.警告框

window.alert("msg");

2.確認(rèn)框

window.confirm("msg");

3.詢問框

window.prompt("msg","defaulvalue")

頁(yè)面

1.打開一個(gè)窗口

window.open()

2.在子窗口中使用,表示父窗口的window對(duì)象

window.opener

window.opener.fatherSayHello(); 調(diào)用父窗口的方法window.opener.a

3.關(guān)閉當(dāng)前窗口

window.close()

window.close(); 關(guān)閉當(dāng)前window.opener.close(); 關(guān)閉父窗口

定時(shí)任務(wù)

1.定時(shí)任務(wù)

var taskid = window.setTimeout(function,ms);window.setTimeout("alert('hello!')", 5000);

2.間隔執(zhí)行任務(wù)

var taskid = window.setInteval(function,ms);

3.清除定時(shí)任務(wù)

window.clearTimeout(taskid);

4.清除間隔執(zhí)行任務(wù)

window.clearInteval(taskid);

打印屏幕

//長(zhǎng)*寬console.log(screen.width + "*" + screen.height)

后退

window.history.back();

前進(jìn)

window.history.forward();

刷新

window.location.reload();//刷新window.location.href = window.location.href;//刷新

Go 前進(jìn)(x)步,后退(x)步,刷新(0),

window.history.go(x)

鏈接

window.location.href = http://www.baidu.com;

用戶代理 瀏覽器內(nèi)核

console.log(window.navigator.userAgent)

框窗

//凡是window的屬性和方法,均可以省略“window.”<script type="application/javascript">// 警告框function testAlert(){var result=window.alert("這是一個(gè)警告框")console.log(result);}// confirm 確認(rèn)框function testConfirm(){var result =window.confirm("你確認(rèn)要離開了嗎?");if(result){alert("歡迎下次再來!")}else{alert("那你在逛逛吧!")}consol.log(result);}// prompt 詢問框function testPrompt(){var result = window.prompt("請(qǐng)輸入U(xiǎn)盾密碼","例如:123456");console.log(result);}</script><body><button onclick="testAlert();">testAlert</button><button onclick="testConfirm();">testConfirm</button><button onclick="testPrompt();">testPrompt</button></body>

頁(yè)面

//子頁(yè)面<script type="application/javascript">function sayHello(){alert("hello world")}//打開一個(gè)窗口function callFatherMethod(){window.opener.fatherSayHello();window.opener.a}//關(guān)閉本窗口function testClose(){window.close();}//關(guān)閉父窗口function testFatherClose(){window.opener.close();}</script><body><button onclick="callFatherMethod()">調(diào)用父窗口的方法</button><button onclick="testClose()">關(guān)閉本窗口</button><button onclick="testFatherClose()">關(guān)閉父窗口</button></body>//父頁(yè)面<script type="application/javascript">var a = 10;window.onload = function(){console.log(window);console.log("11111111111")}//打開一個(gè)新窗口function testOpen(){var sonwindow = window.open("son.html","aaa","height=300,width=500,top=50,left=50,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")//子窗口的window對(duì)象console.log(sonwindow);}function fatherSayHello(){alert("hello son!");}</script><body><button onclick="testOpen();">打開一個(gè)新窗口</button></body>            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 湖南省| 沂源县| 安国市| 同江市| 卓资县| 东方市| 库尔勒市| 连平县| 汉寿县| 和平县| 琼海市| 成武县| 阿城市| 缙云县| 辽中县| 大厂| 鹤峰县| 集贤县| 大安市| 华亭县| 克什克腾旗| 麻江县| 元氏县| 塔河县| 隆回县| 古丈县| 廉江市| 菏泽市| 普陀区| 绥德县| 江门市| 抚宁县| 桐柏县| 宁德市| 贵阳市| 株洲市| 榆社县| 龙岩市| 诸城市| 南召县| 鞍山市|