Heim  >  Artikel  >  Web-Frontend  >  脚本收藏iframe_javascript技巧

脚本收藏iframe_javascript技巧

WBOY
WBOYOriginal
2016-05-16 19:27:55765Durchsuche

1、无提示关闭窗口


2、防止被人iframe
if (top.location != self.location)
{
  top.location.href="http://www.34do.net";
}

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、打开模态窗口
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、模态窗口刷新父窗口
window.parent.dialogArguments.document.execCommand('Refresh');

8、一个js文件包含另外一个js文件
document.write('<script><\/script>'); <br><br>9、让文字竖着写 <BR><td style="Writing-mode:tb-rl;">佛罗伦 <br><br>10、iframe引用自己 <BR>window.parent.document.getElementById("iframe_dg") <BR>这样在iframe文件里就可以操作它自己,比如:window.parent.document.getElementById("iframe_dg").height=200 <br><br>11、根据内容自动调整IFrame高度 <BR>function autoSetIframeSize() <BR>{ <BR> var obj=self.parent.parent.document.all[self.name]; <BR> if(obj!=null) <BR> { <BR> self.parent.parent.document.all[self.name].style.pixelHeight=self.document.body.scrollHeight+5; <BR> } <BR>} <BR>必须定义iframe的name属性 <BR><iframe id="iframe1" name="iframe1" align="middle" frameborder="0" width="100%" height="250" scrolling="no" src="a.asp"> <BR>将a.asp的<body>修改为: <BR><body onload="autoSetIframeSize()"> <br><br>12、为单元格添加渐变色效果(ie支持,firefox不支持) <BR>.bg3 <BR>{ <BR> FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr=#842B00, EndColorStr=#FFFFFF); <BR>} <BR>效果如图 <br><br><BR>13、定时执行任务 <BR>规定一项任务在一定时间内执行:delayID=setTimeout(vCode, iMilliSeconds),在需要的时候,可以强制停止该任务:clearTimeout(delayID) <br><br>14、自动选中复制 <BR><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')" >选中我并复制我 <br><br>15、产生随机数 <BR>VB的Rnd函数产生的随机数范围为0-1。假如要从(min,max)这个范围内随机抽取一个数,具体公式如下: 随机数 = (max - min) * Rnd() + min,min和max可以是任意整数,只是min<max。 <br><br>16、限制文本框只能输入正整数 <BR><input onKeyUp="this.value=this.value.replace(/[^\d]/g,'')"> </script>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn