脚本收藏iframe
收藏 脚本 iframe
2023-06-13 09:13:47 时间
1、无提示关闭窗口
<input type="button" onClick="window.opener = "";window.close();" value="IE6最简单的无提示关闭窗口" >
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 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、根据内容自动调整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、定时执行任务
规定一项任务在一定时间内执行:delayID=setTimeout(vCode, iMilliSeconds),在需要的时候,可以强制停止该任务: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、产生随机数
VB的Rnd函数产生的随机数范围为0-1。假如要从(min,max)这个范围内随机抽取一个数,具体公式如下: 随机数 = (max - min) * Rnd() + min,min和max可以是任意整数,只是min<max。
16、限制文本框只能输入正整数
<input onKeyUp="this.value=this.value.replace(/[^\d]/g,"")">
<input type="button" onClick="window.opener = "";window.close();" value="IE6最简单的无提示关闭窗口" >
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 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、根据内容自动调整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、定时执行任务
规定一项任务在一定时间内执行:delayID=setTimeout(vCode, iMilliSeconds),在需要的时候,可以强制停止该任务: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、产生随机数
VB的Rnd函数产生的随机数范围为0-1。假如要从(min,max)这个范围内随机抽取一个数,具体公式如下: 随机数 = (max - min) * Rnd() + min,min和max可以是任意整数,只是min<max。
16、限制文本框只能输入正整数
<input onKeyUp="this.value=this.value.replace(/[^\d]/g,"")">
相关文章
- Java项目毕业设计:基于springboot+vue的电影视频网站系统「建议收藏」
- Linux下Jboss安装使用+Jboss部署脚本「建议收藏」
- 一个简单的Python暴力激活成功教程网站登录密码脚本「建议收藏」
- 【开源分享】教你如何在HTML中执行Python脚本代码!超级简单赶紧收藏。
- 批处理框架spring batch基础知识介绍「建议收藏」
- 使用IntelliJ IDEA 配置Maven(入门)「建议收藏」
- lamda 表达式「建议收藏」
- C语言中open函数「建议收藏」
- maven项目 porm.xml中Dependency Scope属性「建议收藏」
- MD5加密「建议收藏」
- YUI Compressor完成代码混淆示例「建议收藏」
- linux下设置定时执行脚本「建议收藏」
- 结构体赋值和指针赋值「建议收藏」
- ValueError: too many values to unpack (expected 4)错误,小波变换函数 wavedec2 使用时提示的「建议收藏」
- ArcGIS二次开发基础教程(07):简单符号及图层渲染「建议收藏」
- 数据库简介与 Mysql 服务基础「建议收藏」
- Java中JDK和JRE的区别是什么?它们的作用分别是什么?「建议收藏」
- 值得收藏的几款渗透测试常用的脚本