JavaScript中bom是什么

這篇文章將為大家詳細(xì)講解有關(guān)JavaScript中bom是什么,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

10余年的梁園網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整梁園建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“梁園網(wǎng)站設(shè)計(jì)”,“梁園網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

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>

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

<script type="application/javascript">
function setTime() {
// window.setTimeout("alert('hello!')",5000);
window.setTimeout(sayHello, 5000);
}
var sayHello = function () {
alert("你好!");
}
</script>
</head>
<body>
<button onclick="sayHello();">調(diào)用sayHello</button>
<button onclick="setTime();">調(diào)用setTime</button>

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

<script type="application/javascript">
/*
window.onload = function(){
window.setTimeout(closeSelf, 1000);
}
function closeSelf() {
var secval = document.getElementById("sec").innerHTML;
var secint = parseInt(secval);
document.getElementById("sec").innerHTML = --secint;
if(secint == 0){
window.close();
}
window.setTimeout(closeSelf, 1000);
}
*/

var taskid = 0;
window.onload = function(){
//間隔執(zhí)行任務(wù),間隔 1000ms 執(zhí)行一次
taskid = window.setInterval(closeSelf, 1000);
}
function closeSelf() {
//獲取 10s 
var secval = document.getElementById("sec").innerHTML;
console.log(secval);
var secint = parseInt(secval);
console.log(secint);
//10s 減減
document.getElementById("sec").innerHTML = --secint;
if(secint == 0){
window.close();
}
}
// 4.清除間隔執(zhí)行任務(wù) 暫停
function stopTask(){
window.clearInterval(taskid);
}
//繼續(xù)計(jì)時(shí)
function goonTask(){
taskid = window.setInterval(closeSelf, 1000);
console.log(taskid)
}
</script>
<body>
付款成功,頁(yè)面將在<span id="sec">10</span>s后關(guān)閉。
<button onclick="stopTask()">稍等,待會(huì)我會(huì)自己關(guān)閉</button>
<button onclick="goonTask()">繼續(xù)讀秒,關(guān)閉窗口</button>
</body>

關(guān)于“JavaScript中bom是什么”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

文章題目:JavaScript中bom是什么
鏈接地址:http://muchs.cn/article4/gdieie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站營(yíng)銷、網(wǎng)站制作、軟件開發(fā)網(wǎng)站收錄、網(wǎng)頁(yè)設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)