欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript常用對(duì)話框小集

 更新時(shí)間:2013年09月13日 17:16:35   作者:  
對(duì)話框,大家對(duì)這個(gè)詞匯可謂是各有所解,本文有個(gè)不錯(cuò)的例子,里面包含了各種常見(jiàn)對(duì)話框的實(shí)現(xiàn),感興趣的朋友可以了解下
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function confirmFun() {
//window 是文檔對(duì)象模型的最頂層對(duì)象,

//在調(diào)用它下面的自對(duì)象或方法時(shí)window可省:confirm("是否刪除?");

//這里會(huì)在頁(yè)面的最上方彈出一個(gè)可以選擇是或者否的對(duì)話框,其方法返回一個(gè)bool值,如果選擇了是返回true,選擇了否返回false
var b = window.confirm("是否刪除?");
if (b) {
alert("正在刪除中...");
} else {
alert("取消了刪除...");
}
}
//彈出對(duì)話框

function propmtFun() {

//這里提供了一個(gè)帶有輸入框的對(duì)話框,它的返回值是你輸入的內(nèi)容
//propmt(提示消息,默認(rèn)值)//輸入的內(nèi)容不是習(xí)近平時(shí)再次彈出,直到輸入對(duì)了為止
var re = window.prompt("國(guó)家主席是誰(shuí)?", "死了");
while (re != "習(xí)近平") {
re = window.prompt("國(guó)家主席是誰(shuí)?", "死了");
// propmtFun();
}
alert("歡迎進(jìn)入...");
}


//彈出頁(yè)面

function openFun() {

//這里可以彈出一個(gè)新的頁(yè)面,在這個(gè)方法的參數(shù)里可以設(shè)置頁(yè)面的高度等屬性
//window.open(要打開(kāi)的頁(yè)面的路徑,頁(yè)面的名稱(chēng),頁(yè)面的屬性)
window.open("demo.htm", "", "top=0,left=0,width=300,height=200,location=no,toolbar=no,menubar=no,status=no");
}

//延時(shí)執(zhí)行
var vs = null;
function timeoutFun() {
var vf = function () { alert("hello"); };

//延時(shí)執(zhí)行的操作可以用一個(gè)變量記錄下來(lái)

//設(shè)置多少毫秒后執(zhí)行,參數(shù)是一個(gè)方法,和延遲的時(shí)間
vs = setTimeout(vf, 2000); //2000毫秒后執(zhí)行vf方法
}


//取消延時(shí)執(zhí)行

function cleartimeoutFun() {

//取消延遲執(zhí)行,方法的參數(shù)是一個(gè)setTimeout()方法
window.clearTimeout(vs);
}

//間隔執(zhí)行
var vi = null;
function intervalFun() {
var vf = function () {
var vt = new Date();

// alert(vt.toLocaleTimeString());

//在瀏覽器的狀態(tài)欄顯示當(dāng)前時(shí)間
window.status = vt.toLocaleTimeString();
var text = window.document.getElementById("msg").value = vt.toLocaleTimeString();

};

//設(shè)置vf方發(fā)每隔1000毫秒執(zhí)行一次
vi = window.setInterval(vf, 1000); //每個(gè)1000毫秒執(zhí)行一次vf方法
}

//停止間隔執(zhí)行
function clearintervalFun() {
window.clearInterval(vi);
}

//新消息提示
function msgFun() {
var str = "";
var vstr = "您有新短消息,請(qǐng)注意查收...";
window.document.title = str;
window.document.bgColor = "blue";
var i = 1;
setInterval(function () { window.document.title = vstr.substr(i, 50); i++; if (i == vstr.length) { i = 0; } }, 500)
}
</script>
</head>
<body>
<input type="button" value="是否對(duì)話框" onclick="confirmFun();" /><br />
<input type="button" value="輸入框" onclick="propmtFun();" /><br />
<input type="button" value="彈出頁(yè)面" onclick="openFun();" /><br />
<input type="text" id="msg" /><br />
<input type="button" value="延時(shí)執(zhí)行" onclick="timeoutFun();" /><br />
<input type="button" value="取消延時(shí)" onclick="cleartimeoutFun();" /><br />
<input type="button" value="間隔執(zhí)行" onclick="intervalFun();" /><br />
<input type="button" value="停止間隔執(zhí)行" onclick="clearintervalFun();" /><br />
<input type="button" value="新消息提示" onclick="msgFun();" /><br />
</body>
</html>

相關(guān)文章

最新評(píng)論