腳本收藏iframe
更新時間:2006年07月21日 00:00:00 作者:
1、無提示關(guān)閉窗口
<input type="button" onClick="window.opener = '';window.close();" value="IE6最簡單的無提示關(guān)閉窗口" >
2、防止被人iframe
if (top.location != self.location)
{
top.location.;
}
3、判斷一個對象存在不存在
document.all("a")==null(不存在)
4、彈出子窗口
window.open ('default.asp', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
5、打開模態(tài)窗口
window.showModalDialog('default.asp',window,'help: No; resizable: No; status: No;scrollbars:No;center: Yes;dialogWidth:width;dialogHeight:height;')
6、彈出的子窗口刷新父窗口
window.parent.location.reload();
7、模態(tài)窗口刷新父窗口
window.parent.dialogArguments.document.execCommand('Refresh');
8、一個js文件包含另外一個js文件
document.write('<script src="/b_trade/public/new/public.js"><\/script>');
9、讓文字豎著寫
<td style="Writing-mode:tb-rl;">佛羅倫</td>
10、iframe引用自己
window.parent.document.getElementById("iframe_dg")
這樣在iframe文件里就可以操作它自己,比如:window.parent.document.getElementById("iframe_dg").height=200
11、根據(jù)內(nèi)容自動調(diào)整IFrame高度
function autoSetIframeSize()
{
var obj=self.parent.parent.document.all[self.name];
if(obj!=null)
{
self.parent.parent.document.all[self.name].style.pixelHeight=self.document.body.scrollHeight+5;
}
}
必須定義iframe的name屬性
<iframe id="iframe1" name="iframe1" align="middle" frameborder="0" width="100%" height="250" scrolling="no" src="a.asp"></iframe>
將a.asp的<body>修改為:
<body onload="autoSetIframeSize()">
12、為單元格添加漸變色效果(ie支持,firefox不支持)
.bg3
{
FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr=#842B00, EndColorStr=#FFFFFF);
}
效果如圖
13、定時執(zhí)行任務(wù)
規(guī)定一項任務(wù)在一定時間內(nèi)執(zhí)行:delayID=setTimeout(vCode, iMilliSeconds),在需要的時候,可以強制停止該任務(wù):clearTimeout(delayID)
14、自動選中復制
<span onmouseover="var obj=document.body.createTextRange();obj.moveToElementText(this);obj.select();obj.execCommand('Copy')" onclick="var obj=document.body.createTextRange();obj.moveToElementText(this);obj.select();obj.execCommand('Copy')" >選中我并復制我</span>
15、產(chǎn)生隨機數(shù)
VB的Rnd函數(shù)產(chǎn)生的隨機數(shù)范圍為0-1。假如要從(min,max)這個范圍內(nèi)隨機抽取一個數(shù),具體公式如下: 隨機數(shù) = (max - min) * Rnd() + min,min和max可以是任意整數(shù),只是min<max。
16、限制文本框只能輸入正整數(shù)
<input onKeyUp="this.value=this.value.replace(/[^\d]/g,'')">
<input type="button" onClick="window.opener = '';window.close();" value="IE6最簡單的無提示關(guān)閉窗口" >
2、防止被人iframe
if (top.location != self.location)
{
top.location.;
}
3、判斷一個對象存在不存在
document.all("a")==null(不存在)
4、彈出子窗口
window.open ('default.asp', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
5、打開模態(tài)窗口
window.showModalDialog('default.asp',window,'help: No; resizable: No; status: No;scrollbars:No;center: Yes;dialogWidth:width;dialogHeight:height;')
6、彈出的子窗口刷新父窗口
window.parent.location.reload();
7、模態(tài)窗口刷新父窗口
window.parent.dialogArguments.document.execCommand('Refresh');
8、一個js文件包含另外一個js文件
document.write('<script src="/b_trade/public/new/public.js"><\/script>');
9、讓文字豎著寫
<td style="Writing-mode:tb-rl;">佛羅倫</td>
10、iframe引用自己
window.parent.document.getElementById("iframe_dg")
這樣在iframe文件里就可以操作它自己,比如:window.parent.document.getElementById("iframe_dg").height=200
11、根據(jù)內(nèi)容自動調(diào)整IFrame高度
function autoSetIframeSize()
{
var obj=self.parent.parent.document.all[self.name];
if(obj!=null)
{
self.parent.parent.document.all[self.name].style.pixelHeight=self.document.body.scrollHeight+5;
}
}
必須定義iframe的name屬性
<iframe id="iframe1" name="iframe1" align="middle" frameborder="0" width="100%" height="250" scrolling="no" src="a.asp"></iframe>
將a.asp的<body>修改為:
<body onload="autoSetIframeSize()">
12、為單元格添加漸變色效果(ie支持,firefox不支持)
.bg3
{
FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr=#842B00, EndColorStr=#FFFFFF);
}
效果如圖
13、定時執(zhí)行任務(wù)
規(guī)定一項任務(wù)在一定時間內(nèi)執(zhí)行:delayID=setTimeout(vCode, iMilliSeconds),在需要的時候,可以強制停止該任務(wù):clearTimeout(delayID)
14、自動選中復制
<span onmouseover="var obj=document.body.createTextRange();obj.moveToElementText(this);obj.select();obj.execCommand('Copy')" onclick="var obj=document.body.createTextRange();obj.moveToElementText(this);obj.select();obj.execCommand('Copy')" >選中我并復制我</span>
15、產(chǎn)生隨機數(shù)
VB的Rnd函數(shù)產(chǎn)生的隨機數(shù)范圍為0-1。假如要從(min,max)這個范圍內(nèi)隨機抽取一個數(shù),具體公式如下: 隨機數(shù) = (max - min) * Rnd() + min,min和max可以是任意整數(shù),只是min<max。
16、限制文本框只能輸入正整數(shù)
<input onKeyUp="this.value=this.value.replace(/[^\d]/g,'')">
相關(guān)文章
JS+CSS實現(xiàn)六級網(wǎng)站導航主菜單效果
這篇文章主要介紹了JS+CSS實現(xiàn)六級網(wǎng)站導航主菜單效果,涉及JavaScript遍歷頁面元素及動態(tài)修改css屬性的相關(guān)實現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09
BootStrap智能表單實戰(zhàn)系列(七)驗證的支持
這篇文章主要介紹了BootStrap智能表單實戰(zhàn)系列(七)驗證的支持 ,凡是涉及到用戶編輯信息然后保存的頁面,都涉及到一個數(shù)據(jù)是否符合要求的檢查,需要客服端和服務(wù)器端的校驗的問題,本文介紹非常詳細,具有參考價值,需要的朋友可以參考下2016-06-06
js中的關(guān)聯(lián)數(shù)組與普通數(shù)組詳解
下面小編就為大家?guī)硪黄猨s中的關(guān)聯(lián)數(shù)組與普通數(shù)組詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07

