var MoveDiv = function() { }; /**
* @deprecated 移动div的方法
* @param{id} id 要移动的层ID
*/
MoveDiv.Move = function(id) {
var o = document.getElementById(id); o.onselectstart = function() {
return (false);
}; o.onmousedown = function(e) {
e = e || window.event;
var x = e.layerX || e.offsetX;
var y = e.layerY || e.offsetY; document.onmousemove = function(e) {
e = e || window.event;
o.style.left = (e.clientX - x) + "px";
o.style.top = (e.clientY - y) + "px";
}; document.onmouseup = function() {
document.onmousemove = null;
};
};
} -------------
这个函数怎么在Firefox下好好的,怎么在IE下一抖一抖的? 还出现鼠标不按下也移动的状况。
* @deprecated 移动div的方法
* @param{id} id 要移动的层ID
*/
MoveDiv.Move = function(id) {
var o = document.getElementById(id); o.onselectstart = function() {
return (false);
}; o.onmousedown = function(e) {
e = e || window.event;
var x = e.layerX || e.offsetX;
var y = e.layerY || e.offsetY; document.onmousemove = function(e) {
e = e || window.event;
o.style.left = (e.clientX - x) + "px";
o.style.top = (e.clientY - y) + "px";
}; document.onmouseup = function() {
document.onmousemove = null;
};
};
} -------------
这个函数怎么在Firefox下好好的,怎么在IE下一抖一抖的? 还出现鼠标不按下也移动的状况。
解决方案 »
- ASP .NET页面数据传递
- 问一个关于div属性的问题
- 谁知道好点的广州.NET群(少瞎聊的)?
- SQL2000.特殊insert.要插入包含单引号与逗号的值.请高手解答!
- 菜鸟问题 :Datagrid显示数据库里面的数据
- asp.net 页面
- 如何在DataSet中寻找某行某列的值?
- 用ASP.NET C#,如何显示MS SQL Server 2000中的Text字段?
- 高手看看,就这些分了!多谢!
- 使用ASP.NET写服务器端, 实现与移动端通过json来通信...求告知怎么做
- DATALIST分页中,ViewState["typeid"]怎么回事?
- 一次输入几行数据,有一行不输入,数据库中就有一条空的数据
--
function DragDiv(ID) {
var isIe = (document.all) ? true : false;
if (isIe) {
MoveForIE(ID);
}
else {
MoveForFF(ID);
}
}看我牛不牛,哈哈。。老妖,过来接分了。。
function getEvent() {
return window.event || arguments.callee.caller.arguments[0];
}e = getEvent();
<head runat="server">
<title></title>
<style type="text/css">
html, body
{
font-size: 12px;
margin: 0px;
height: 100%;
}
.mesWindow
{
z-index: 1001;
border: #666 1px solid;
background: #fff;
}
.mesWindowTop
{
border-bottom: #eee 1px solid;
margin-left: 4px;
padding: 3px;
font-weight: bold;
text-align: left;
font-size: 12px;
height: 20px;
cursor: move;
}
.mesWindowContent
{
margin: 4px;
font-size: 12px;
vertical-align: middle;
}
.mesWindow .close
{
text-align: right;
cursor: pointer;
}
</style> <script type="text/javascript">
//判断浏览器是否为IE
var isIe = (document.all) ? true : false;
//弹出方法
function showMessageBox(wTitle, content) {
var msgw, msgh, bordercolor;
msgw = 380; //提示窗口的宽度
msgh = 120; //提示窗口的高度
titleheight = 25 //提示窗口标题高度
bordercolor = "#333"; //提示窗口的边框颜色
titlecolor = "#445588"; //提示窗口的标题颜色 closeWindow();
var bWidth = parseInt(document.body.scrollWidth); //网页正文全文宽
var bHeight = parseInt(window.screen.availHeight); //网页正文全文高
var back = document.createElement("div"); //创建北京div对象
back.id = "back";
var styleStr = "top:0px;left:0px;position:absolute;background:#666;width:" + bWidth + "px;height:" + bHeight + "px;";
styleStr += (isIe) ? "filter:alpha(opacity=50);" : "opacity:0.1;";
back.style.cssText = styleStr;
back.style.zIndex = "1000";
if (isIe) {
back.innerHTML = "<iframe style='position: absolute; width:\"100%\"; height:\"100%\";' frameborder='0'> </iframe>";
}
document.body.appendChild(back);
//showBackground(back, 50);
var mesW = document.createElement("div"); //创建信息窗口对象div
mesW.id = "mesWindow";
mesW.className = "mesWindow";
mesW.innerHTML = "<div class='mesWindowTop' onmousedown=\"DragDiv('mesWindow')\">"
+ "<table width='100%' height='100%'>"
+ "<tr>"
+ "<td>" + wTitle + "</td>"
+ "<td align='right'><a onclick='closeWindow();' title='关闭窗口' class='close'>关闭</a></td>"
+ "</tr></table></div>"
+ "<div class='mesWindowContent' id='mesWindowContent'>" + content + "</div>"
+ "<div class='mesWindowBottom'></div>";
//styleStr = "left:" + (((pos.x - wWidth) > 0) ? (pos.x - wWidth) : pos.x) + "px;top:" + (pos.y) + "px;position:absolute;width:" + wWidth + "px;";
styleStr = "left:" + (bWidth - msgw) / 2 + "px;top:35%;position:absolute;width:" + msgw + "px;height:" + msgh + "px;text-align:center;";
mesW.style.cssText = styleStr;
document.body.appendChild(mesW);
}
function closeWindow() {
if (document.getElementById('back') != null) {
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if (document.getElementById('mesWindow') != null) {
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
} function DragDiv(ID) {
var isIe = (document.all) ? true : false;
if (isIe) {
MoveForIE(ID);
}
else {
MoveForFF(ID);
}
}
//拖拽图层
var ms = 0;
function MoveForIE(obj) {
ms = obj;
event.srcElement.setCapture();
x = document.all(ms).style.pixelLeft - event.x;
y = document.all(ms).style.pixelTop - event.y;
} document.onmousemove = function() {
if (ms != "") {
document.all(ms).style.pixelLeft = x + event.x;
document.all(ms).style.pixelTop = y + event.y;
}
} document.onmouseup = function() {
if (ms != "") {
event.srcElement.releaseCapture();
ms = 0;
}
} //测试弹出
function testMessageBox(ev) {
var messContent = "什么东西啊";
showMessageBox('窗口标题', messContent);
}
//
function MoveForFF(id) {
var o = document.getElementById(id); o.onselectstart = function() {
return (false);
}; o.onmousedown = function(e) {
e = e || window.event;
var x = e.layerX || e.offsetX;
var y = e.layerY || e.offsetY; document.onmousemove = function(e) {
e = e || window.event;
o.style.left = (e.clientX - x) + "px";
o.style.top = (e.clientY - y) + "px";
}; document.onmouseup = function() {
document.onmousemove = null;
};
};
} </script></head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<a href="#none" onclick="testMessageBox(event);">弹出窗口</a></div>
<select>
<option value="0">请选择</option>
</select>
<asp:dropdownlist id="DropDownList1" runat="server">
</asp:dropdownlist>
<select id="Select1">
<option></option>
</select>
</form>
</body>
</html>
--
这是源码
唉,最近也被JS搞得好头疼
有时候在IE下好的,FF下不行
有时候IE下好的,FF下也是好的,Chrome下不行
郁闷死