<!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 弹层 和拖动效果的更多相关文章

  1. 使用layui iframe弹层,各弹层之前的传值问题

    最近做一个后台管理系统,用到的layui,主要是使用它的弹层,但是各个弹层之前的传值经常容易搞晕,写个个博客记录一下,方便自己,也方便别人, 首先我的页面已经嵌套了好几个iframe页面了,嵌套了三个 ...

  2. html页面中iframe导致JavaScript失效

    <body onload=“reset()”> <div id="part1"> some thing here .... <div> < ...

  3. Jquery 操作页面中iframe自动跟随窗口大小变化,而页面不出现滚动条,只在iframe内部出滚动条

    很多时候大家需要iframe自适应所加载的页面高度而不要iframe滚动条,但是这次我需要的是页面不需要滚动条而iframe要滚动条,且iframe自动跟随窗口大小变化.自适应页面大小.下面是代码,下 ...

  4. 页面中iframe中嵌入一个跨域的页面,让这个页面按照嵌入的页面宽高大小显示的方式;iframe嵌套的页面不可以编辑的问题解决方案

    <html> <head> <style> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; ...

  5. 当页面中(比如弹出框SelectPage)没有textbox等控件如何按Esc关闭

    1.在网页上添加一个空白的ASPxTextBox控件 <dxe:ASPxTextBox ID="txt_Name" Width="1" runat=&qu ...

  6. PHP中如何实现 “在页面中一边执行一边输出” 的效果

    <?php    set_time_limit(0);  //在有关数据库的大量数据的时候,可以将其设置为0,表示无限制.    ob_end_clean();     //在循环输出前,要关闭 ...

  7. Layer组件多个iframe弹出层打开与关闭及参数传递

    一.Layer简介 Layer是一款近年来备受青睐的web弹层组件,基于jquery,易用.实用,兼容包括IE6在内的所有主流浏览器,拥有丰富强大的可自定义的功能. Layer官网地址:http:// ...

  8. layui中从子窗口传递数据到父窗口,第三个子弹层的值传给第二个弹层

    最近做一个项目的需要多个弹层,每个弹层中还需要数据传递, 经过测试,以下方法三个弹层才有效,如果只是有两个弹层,请用其它方法 大概如图,看图自己应该明白 如何在在b页面选择好的值传给a页面的问题,这个 ...

  9. 弹层组件-layer

    layer是Layui的一个弹层组建,功能强大,总之我很喜欢,下面介绍这个组件的基本用法. 首先如果只需要使用layer而不想使用Layui可以单独下载layer组件包,页面引入jquery1.8以上 ...

随机推荐

  1. react使用总结

    1.拿到页面首先需要设计好,每个组件该怎么实现,划分好组件可以减少重复代码,有的时候需要和后端确认才能形成正确的划分 2.页面上的需要展示的数据都是由后端数据而来,所以任何增删改查的数据都要从后端重新 ...

  2. python爬虫爬取ip记录网站信息并存入数据库

    import requests import re import pymysql #10页 仔细观察路由 db = pymysql.connect("localhost",&quo ...

  3. ethtool---查看网卡

    ethtool 命令详解 命令描述: ethtool 是用于查询及设置网卡参数的命令. 使用概要:ethtool ethx       //查询ethx网口基本设置,其中 x 是对应网卡的编号,如et ...

  4. element-ui中table渲染的快速用法

    element-ui中对table数据的渲染有一些模板式的操作,基本按照模板渲染数据即可 基本模板样式如下 <el-table :data="studentData.rows" ...

  5. vue 点击切换图标

    <div @click="showImg" class="showSearch"> <img class="header_img&q ...

  6. python使用xlrd读取excel数据

    一.安装xlrd 库的安装我这里就不说了.. 二.读取 excel 前提条件:excel文件名称为 excel_data.xlsx 1.打开excelw 文件 workbook = xlrd.open ...

  7. 新建门脸Facade类

    1.App\Contract目录下新建 CommonContract 类 <?php namespace App\Contract; use Carbon\Carbon; use \Dimsav ...

  8. spring 结合 redis 例子 (转)

    好了费话不多说了,介绍下spring 结合redis是怎么操作数据的 这里我用了maven管理,由于简单嘛,依赖下包就行了..不用单独去依赖包,成了我的习惯 好了,下面是pom的代码 <proj ...

  9. SQL的判断重复新增或者修改

    <insert id="insertTankStatisticData" parameterType="java.util.Map"> <se ...

  10. python基础特性之函数property

    函数property 1.为了保护属性,不让它随意的被更改(a.width=xxx)(起码,要符合某些条件),所以我们引入了set和get方法,虽然这个需要自定义(如下图的set_size,get_s ...