`
awaitdeng
  • 浏览: 214081 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

JS与DIV弹出层实例!

阅读更多
为了设计GPS地图显示轨迹程序  为了查询某段时间的轨迹而想设计一个弹窗对话层

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>hihi</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
/**
* 弹出层css
*/
.pop {
width: 80%;
border: 1px #96D1DF solid;
background: #fff;
padding: 1px;
color: #333;
position: absolute;
top: 15%;
left: 15%;
height: auto;
z-index: 10
}

/**
* 弹出层css
*/
.pop_ {
width: 80%;
border: 1px #96D1DF solid;
background: #fff;
padding: 1px;
color: #333;
position: absolute;
top: 15%;
left: 15%;
height: auto;
z-index: 10
}

.pop_title {
float: left;
width: 100%;
height: 24px;
line-height: 24px;
/* background: #ecf9ff url ('../images/title_move.gif') center no-repeat; */
background: #ecf9ff;
border-bottom: 1px #d3ecf3 solid;
color: #444;
font-weight: bold
}

.pop_title_left {
float: left;
width: 90%;
overflow: hidden;
text-indent: 6px;
cursor: move
}

.pop_title_left img {
float: left;
border: 0;
margin: 10px 0 0 5px
}

.pop_title_right {
width: 5%;
float: right;
text-align: right;
cursor: pointer
}

.pop_title_right_print {
width: 3%;
float: left;
text-align: right
}

.pop_title_right img {
margin: 5px 10px 5px 10px;
cursor: pointer
}

.pop_title_right_print img {
margin: 5px 10px 5px 10px;
cursor: pointer
}

.pop_content {
float: left;
width: 100%;
margin: 1px 0 50 0;
font-size: 14px
}

.pop_function {
float: left;
width: 100%;
height: 30px;
line-height: 30px;
border-top: 1px #fff solid;
text-align: center
}

.pop_search {
width: 100%;
height: 35px;
border-top: 1px #fff solid;
text-align: center;
font-size: 12px;
font-weight: bold;
margin: 5px 0 5px 0;
border-bottom: 3px #96D1DF dotted;
}

.pop_page {
width: 100%;
height: 25px;
text-align: center;
font-size: 12px;
border-top: 3px #96D1DF dotted;
vertical-align: middle;
}
</style>
<script type='text/javascript' src='<%=basePath%>/My97DatePicker/WdatePicker.js'></script>
<script>
function getxy(e) {
var a = new Array();
var t = e.offsetTop;
var l = e.offsetLeft;
var w = e.offsetWidth;
var h = e.offsetHeight;
while (e = e.offsetParent) {
t += e.offsetTop;
l += e.offsetLeft;
}
a[0] = t;
a[1] = l;
a[2] = w;
a[3] = h;
return a;
}
//----------------------------------
var DragForAll = {};
function _enableDragForAll(e, toMoveObj, obj2, obj3) {
if (DragForAll.o) {
return false;
}
var clickObj = document.getElementById(toMoveObj);
if (!clickObj) {
return;
}
DragForAll.o = clickObj;
if (document.getElementById(obj2)) {
DragForAll.p = document.getElementById(obj2);
}
DragForAll.xy = getxy(DragForAll.o);
e = e || event;
if (!clickObj.style.left) {
DragForAll.xx = new Array((e.x - DragForAll.xy[1]), (e.y - DragForAll.xy[0]));
} else {
DragForAll.xgap = parseInt(clickObj.style.left.substring(0, clickObj.style.left.indexOf("px")));
DragForAll.ygap = parseInt(clickObj.style.top.substring(0, clickObj.style.top.indexOf("px")));
DragForAll.xx = new Array((e.x - DragForAll.xgap), (e.y - DragForAll.ygap));
DragForAll.xgap -= DragForAll.xy[1];
DragForAll.ygap -= DragForAll.xy[0];
}
DragForAll.fitToCont = obj3;
if (obj3) {
DragForAll.fitArea = getxy(DragForAll.fitToCont);
}
return false;
}
function _DragObjForAll(e) {
if (!DragForAll.o) {
return;
}
e = e || event;
var old_left = e.x - DragForAll.xx[0];
var old_top = e.y - DragForAll.xx[1];
if (DragForAll.fitToCont) {
if ((old_left - DragForAll.xgap) - DragForAll.fitArea[1] <= 0 || old_top - DragForAll.ygap - DragForAll.fitArea[0] <= 0) {
return;
}
if (old_left - DragForAll.xgap + DragForAll.xy[2] >= DragForAll.fitArea[1] + DragForAll.fitArea[2] || old_top - DragForAll.ygap + DragForAll.xy[3] >= DragForAll.fitArea[0] + DragForAll.fitArea[3]) {
return;
}
}
DragForAll.o.style.left = old_left + "px";
DragForAll.o.style.top = old_top + "px";
if (DragForAll.p) {
DragForAll.p.style.left = (old_left + 5) + "px";
DragForAll.p.style.top = (old_top + 5) + "px";
}
}
function _releaseDragObjForAll(e) {
DragForAll = {};
}
document.onmousemove = function (e) {
_DragObjForAll(e);
};
document.onmouseup=function(e){
_releaseDragObjForAll(e);
e=e||event;
}

function showValue(){
       var v1 =document.getElementById("d241").value;
       var v2 =document.getElementById("d233").value;
       document.getElementById("xingZQYTree").style.display='none';
       alert(v1+v2);
   }
</script>
</head>
<body>
<input type="button" value="弹出DIV窗口"
onclick="xingZQYTree.style.display='';xingZQYTree.style.top=event.clientY;xingZQYTree.style.left=event.clientX" />


<div id="xingZQYTree" class="pop"
style="display: none; width: 480px; overflow: auto; position: absolute; background-color: #FFFFFF; border: 1px solid #0099CC; padding-left: 0px">
<div id="pop_title" class="pop_title"
onmousedown="_enableDragForAll(event,'xingZQYTree');" title='按住鼠标可随意拖动此窗口'>
<div class="pop_title_left" style="font-size: 14px">
&nbsp;&nbsp;选择时间
</div>
<div class="pop_title_right">
<label title="关闭此窗口" onclick="xingZQYTree.style.display='none';">
&nbsp;X&nbsp;
</label>
</div>
</div>
<div class="pop_content">
<div>
<input type="text" id="d241" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" style="width:159px;margin-left: 20px;margin-top: 15px;"/>
&nbsp;至&nbsp;<input type="text" id="d233" onFocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" style="width:159px;margin-right: 15px;margin-top: 15px;"/>
     <a href="#" onclick="showValue();"  style="margin-right: 20px;">查询轨迹</a>
</div>
<!-- <div style="margin-top: 15px;margin-bottom: 20px;"><a href="#" onclick="showValue();"  style="margin-left: 20px;margin-right: 20px;margin-top: 15px;"> </a></div>-->

</div>
</div>
</body>
</html>
分享到:
评论

相关推荐

    JS+DIV以层代替弹出窗口的例子,弹出DIV层窗口

    JS+DIV以层代替弹出窗口的例子,弹出DIV层窗口 JS+DIV以层代替弹出窗口的例子,弹出DIV层窗口 JS+DIV以层代替弹出窗口的例子,弹出DIV层窗口 JS+DIV以层代替弹出窗口的例子,弹出DIV层窗口 JS+DIV以层代替弹出窗口的例子...

    JAVASCRIPT弹出DIV层窗口实例

    JAVASCRIPT弹出DIV层窗口实例

    JS做的隐藏与显示DIV可拖动弹出层

    JS做的隐藏与显示DIV可拖动弹出层实例代码 学习参考

    javascript+html弹出层实例

    在web开发中,实现好看的弹出层效果,能弹出图片,文字,div......

    js实现div弹出层的方法

    主要介绍了js实现div弹出层的方法,以实例的形式完整的实现了js弹出div层的效果,并且弹出层可拖拽、可关闭,用户还可根据个人喜好自定义弹出层的显示效果,非常具有实用价值,需要的朋友可以参考下

    js控制div弹出层实现方法

    本文实例讲述了js控制div弹出层实现方法。分享给大家供大家参考。具体分析如下: 这是个功能很好,且容易调用和控制的弹出层。感兴趣的朋友可以调试运行一下看看效果如何~O(∩_∩)O~ &lt;html&gt; &lt;head&gt; &lt...

    JS弹出可拖拽可关闭的div层完整实例

    主要介绍了JS弹出可拖拽可关闭的div层完整实现方法,包括对div弹出层的样式及功能的实现技巧,非常具有实用价值,需要的朋友可以参考下

    使用JavaScript实现弹出层效果的简单实例

    实现弹出层效果的思路非常简单:将待显示的内容先隐藏,在触发某种条件后(如点击按钮),将原本隐藏的内容显示出来。 实现 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Window对象&lt;/title&gt;...

    JQuery弹出层插件

    JQuery弹出层插件,Popup div 实例,前段弹窗插件

    asp.net后台弹出层,asp.net后台调用前台JS事件

    这是一个用于as.net网页的弹出层对话框的实例,原本弹出提示可以使用alert&#40;'lcng'&#41;,但是由于不太友好,而且不太美观,后来才想自己做一个,当然了网上也有许多弹出对话框的jquery插件,不过平常使用的时候...

    js点击弹出层完整代码下载.rar

    js实现网页上那种点击弹出层的特效代码,支持拖动效果,完整代码下载,这是一个点击文字后弹出一个搜索框的浮动层,基于JS和Div共同实现,用到了几个JavaScript封装类,已为您打包,本弹出层可任意拖动位置,可以...

    js 弹出一个层的实例

    js 弹出一个层的实例,很好用,可以设置层停留的时间

    Js弹出div窗口完美版

    摘要:脚本资源,Ajax/JavaScript,弹出层 收集的JAVAsCRIPT弹出DIV层窗口的实例,引入了jquery-1.4.1.min.js,实例中有一个无边框iframe完美遮罩演示。这些网页特效对于平时的前端设计用处非常大,学习之后也能提高你...

    js点击任意区域弹出层消失实现代码

    本文实例为大家分享了js点击任意区域弹出层消失的具体代码,供大家参考,具体内容如下 采用jquery element.parents();判断点击区域是否在弹出层上面或者在按钮上面,否则让弹出层消失。 完整代码 &lt;!DOCTYPE ...

    JS简单实现点击按钮或文字显示遮罩层的方法

    本文实例讲述了JS简单实现点击按钮或文字显示遮罩层...点击文字弹出一个DIV层窗口代码&lt;/title&gt; &lt;meta charset="urf-8"/&gt; &lt;style&gt; .black_overlay{ display: none; position: absolute; top: 0

    JQuery&CSS;&CSS;+DIV实例大全.rar

    3.jQuery弹出层插件PopupDiv-v1.0下载(支持ajax、居中等效果) 4.jQuery超炫淡入淡出效果DIV渐变居中弹出框插件下载 5.jquery黑色+蓝色风格DIV提示框示例 6.一款jQuery+DIV居中淡入淡出信息提示框示例 7.一...

    js与css实现弹出层覆盖整个页面的方法

    本文实例讲述了js与css实现弹出层覆盖整个页面的方法。分享给大家供大家参考。具体实现方法如下: 弹出层透明背景加框的常用样式和结构如下: 代码如下:.alertMessageBg{ position:fixed; _position:absolute; width...

    【JavaScript源代码】js实现弹框效果.docx

    -- 弹出层 --&gt; &lt;div id="popLayer"&gt;&lt;/div&gt; &lt;!--黑色蒙版 --&gt; &lt;div id="popBox"&gt; &lt;div class="close"&gt; X &lt;/div&gt; &lt;div&gt; &lt;!-- 内容 --&gt; &lt;/div&gt; &lt;/div&gt; js: //点击关闭按钮 var close = document....

Global site tag (gtag.js) - Google Analytics