页面中iframe 弹层 和拖动效果
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的jquery</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
//拖拽窗口
$(function(){
var x,y;
var i=0;
$(".box .tit").mousedown(function(e){
i=1;
x = e.pageX-parseInt($(".box").css("left"));
y = e.pageY-parseInt($(".box").css("top"));
$(".box").fadeTo(200, 0.5);
})
$(document).mousemove(function(e){
if(i == 1){
x2 = e.pageX - x;
y2 = e.pageY - y;
if(x2 < 0){x2 = 0;}
if(x2 > 800){x2 = 800;}
if(y2 < 0){y2 = 0;}
if(y2 > 700){y2 = 700;}
$(".box").css({top:y2,left:x2});
}
}).mouseup(function(){
i=0;
$(".box").fadeTo(200, 1);
})
})
//拖拽窗口end
//iframe弹出层
function tanchuceng(width,height,tit,url){
var winWinth = $(window).width(),winHeight = $(document).height();
$("body").append("<div class='winbj'></div>");
$("body").append("<div class='tanChu'><div class='tanChutit'><span class='tanchuTxt'>"+tit+"</span><span class='tanchuClose'>关闭</span></div><iframe class='winIframe' frameborder='0' hspace='0' src="+ url +"></iframe></div>");
$(".winbj").css({width:winWinth,height:winHeight,background:"#000",position:"absolute",left:"0",top:"0"});
$(".winbj").fadeTo(0, 0.5);
var tanchuLeft = $(window).width()/2 - width/2;
var tanchuTop = $(window).height()/2 - height/2 + $(window).scrollTop();
$(".tanChu").css({width:width,height:height,border:"3px #ccc solid",left:tanchuLeft,top:tanchuTop,background:"#fff",position:"absolute"});
$(".tanChutit").css({width:width,height:"25px","border-bottom":"1px #ccc solid",background:"#eee","line-height":"25px"});
$(".tanchuTxt").css({"text-indent":"5px","float":"left","font-size":"14px"});
$(".tanchuClose").css({"width":"40px","float":"right","font-size":"12px","color":"#666","cursor":"pointer"});
var winIframeHeight = height - 26;
$(".winIframe").css({width:width,height:winIframeHeight,"border-bottom":"1px #ccc solid",background:"#ffffff"});
$(".tanchuClose").hover(
function(){
$(this).css("color","#333");
},function(){
$(this).css("color","#666");
}
);
$(".tanchuClose").click(function(){
$(".winbj").remove();
$(".tanChu").remove();
});
}
//iframe弹出层end
//模仿alert
function mfalert(txt){
var width = $(".mfalert").width() + 20;
var mfalertLeft = $(window).width()/2 - width/2;
var mfalertTop = $(window).height()/2 - 30/2 + $(window).scrollTop();
$("body").append("<div class='mfAlert'>"+txt+"</div>");
$(".mfAlert").css({width:width,height:"30px",border:"1px #333 solid",left:mfalertLeft,top:mfalertTop,background:"#ccc",position:"absolute","text-align":"center","line-height":"30px"});
setTimeout("$('.mfAlert').remove()",3000);
}
//模仿alert end
</script>
<style>
*{padding:0;margin:0;font-size:12px;}
.layout{width:1000px;height:800px;border:1px #000 solid;border-width:0 1px;margin:0 auto;padding:1px; position:relative;}
.box{width:200px;height:100px;border:1px #ccc solid; position:absolute;left:100px;top:20px;}
.box .tit{height:20px;width:100%;background:#eee;border-bottom:1px #ccc solid; line-height:20px; text-indent:10px;}
.box .lis{line-height:20px; text-indent:5px;}
.tanchu{position:absolute; left:20px;top:20px;}
.mfalert{position:absolute; left:20px;top:50px;}
</style>
</head>
<body>
<div class="layout">
<a href="#" class="tanchu" onclick="tanchuceng(600,300,'我是中文','test.html')">弹出层</a>
<div class="box">
<div class="tit">点住我移动</div>
<div class="lis">我是可移动的</div>
</div>
<a href="#" class="mfalert" onclick="mfalert('3秒就没了')">点我输出</a>
</div>
</body>
</html>
页面中iframe 弹层 和拖动效果的更多相关文章
- 使用layui iframe弹层,各弹层之前的传值问题
最近做一个后台管理系统,用到的layui,主要是使用它的弹层,但是各个弹层之前的传值经常容易搞晕,写个个博客记录一下,方便自己,也方便别人, 首先我的页面已经嵌套了好几个iframe页面了,嵌套了三个 ...
- html页面中iframe导致JavaScript失效
<body onload=“reset()”> <div id="part1"> some thing here .... <div> < ...
- Jquery 操作页面中iframe自动跟随窗口大小变化,而页面不出现滚动条,只在iframe内部出滚动条
很多时候大家需要iframe自适应所加载的页面高度而不要iframe滚动条,但是这次我需要的是页面不需要滚动条而iframe要滚动条,且iframe自动跟随窗口大小变化.自适应页面大小.下面是代码,下 ...
- 页面中iframe中嵌入一个跨域的页面,让这个页面按照嵌入的页面宽高大小显示的方式;iframe嵌套的页面不可以编辑的问题解决方案
<html> <head> <style> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; ...
- 当页面中(比如弹出框SelectPage)没有textbox等控件如何按Esc关闭
1.在网页上添加一个空白的ASPxTextBox控件 <dxe:ASPxTextBox ID="txt_Name" Width="1" runat=&qu ...
- PHP中如何实现 “在页面中一边执行一边输出” 的效果
<?php set_time_limit(0); //在有关数据库的大量数据的时候,可以将其设置为0,表示无限制. ob_end_clean(); //在循环输出前,要关闭 ...
- Layer组件多个iframe弹出层打开与关闭及参数传递
一.Layer简介 Layer是一款近年来备受青睐的web弹层组件,基于jquery,易用.实用,兼容包括IE6在内的所有主流浏览器,拥有丰富强大的可自定义的功能. Layer官网地址:http:// ...
- layui中从子窗口传递数据到父窗口,第三个子弹层的值传给第二个弹层
最近做一个项目的需要多个弹层,每个弹层中还需要数据传递, 经过测试,以下方法三个弹层才有效,如果只是有两个弹层,请用其它方法 大概如图,看图自己应该明白 如何在在b页面选择好的值传给a页面的问题,这个 ...
- 弹层组件-layer
layer是Layui的一个弹层组建,功能强大,总之我很喜欢,下面介绍这个组件的基本用法. 首先如果只需要使用layer而不想使用Layui可以单独下载layer组件包,页面引入jquery1.8以上 ...
随机推荐
- react踩坑
1.列表渲染一定要注意key的唯一性,不然会导致页面只更新部分的bug graphVertexConfigList.data.map((item, index) => { return < ...
- C stdarg.h
参考:https://www.cnblogs.com/bettercoder/p/3488299.html 博主:运动和行动 va_start宏,获取可变参数列表的第一个参数的地址(list是类 ...
- 转。Nas配置。想找原版没找到,全是转载的,也没注出处,无语。
随着家用宽带的不断提速和高清电影的普及外带单反的家庭占有率越来越搞,仅靠台式机里那几块硬盘越来越不够用了. 简单的计算了一下,家里的台式机上2T的容量(1T+640G+320G)已经接近于80%满,外 ...
- springBoot框架在idea中创建流程 同时存在一个项目中
1.新建普通maven工程 2.在父级pom中按需修改 3.删除父级src目录 4.创建公共模块common,里面只有service接口和实体类 5.构建微服务模块,provider 6.引用Zook ...
- Hive速览
一.概述 Hive由Facebook开源,是一个构建在Hadoop之上的数据仓库工具 将结构化的数据映射成表 支持类SQL查询,Hive中称为HQL 1.读模式 2.Hive架构 3.使用Hive的原 ...
- leetcode-162周赛-1254-统计封闭岛屿数量
题目描述: 自己的提交: class Solution: def closedIsland(self, grid: List[List[int]]) -> int: def dfs(grid,r ...
- js过滤字符串中的html标签
var str = 'add<a>daad</a><p>fsdada</p>' str.replace(/<[^<>]+>/g, ...
- Android 在OnCreate()中获取控件高度与宽度
试过在OnCreate()中获取控件高度与宽度的童鞋都知道,getWidth()与getHeight()方法返回是0,具体原因 看一下Activity的生命周期 就会明白. 上代码: 方法一: int ...
- BZOJ 3236: [Ahoi2013]作业(莫队+树状数组)
传送门 解题思路 莫队+树状数组.把求\([a,b]\)搞成前缀和形式,剩下的比较裸吧,用\(cnt\)记一下数字出现次数.时间复杂度\(O(msqrt(n)log(n)\),莫名其妙过了. 代码 # ...
- jQuery Validate (摘自官网)
jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证 ...