这个源码~在IE能正常浏览和使用。但是在firefox下背景没变灰,初始位置也不对,也不能拖拽。孟子大哥帮忙修改一下。谢谢了.http://www.talltell.com/alert.rar
解决方案 »
- 大型网站新闻内容在数据库中的存储的几个问题。
- 如何阻止多次弹框
- 新手提问:如何将文件保存入Oracle数据库中?
- asp.net(vb)实现无刷新DropDownList联动???高手指教!
- 【散分求好书推荐!】好书追加给分哦.
- 北大青鸟教程
- 请问如何改变微软提供的Treeview树控件上节点上字的颜色?
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!求asp.net报表打印控件!!!!!!形成后向table那样的,有翻页,打印等功能。
- 请问一个关于DropDownList的问题?
- 为什么没有system.data.ado
- IIS 7:RewriteURL 的问题
- 如何去掉treeview节点前的"+"(该节点已经没有子节点)
<head>
<title>Josh - Test</title>
<style type="text/css">
.opaqueLayer
{
display:none;
position:absolute;
top:0px;
left:0px;
opacity:0.6;
filter:alpha(opacity=60);
background-color: #000000;
z-Index:1000;
}
.questionLayer
{
position:absolute;
top:0px;
left:0px;
width:350px;
height:200px;
display:none;
z-Index:1001;
border:2px solid black;
background-color:#FFFFFF;
text-align:center;
vertical-align:middle;
padding:10px;
}
</style>
<script type="text/javascript">
function getBrowserHeight() {
var intH = 0;
var intW = 0;
if(typeof window.innerWidth == 'number' ) {
intH = window.innerHeight;
intW = window.innerWidth;
}
else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
intH = document.documentElement.clientHeight;
intW = document.documentElement.clientWidth;
}
else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
intH = document.body.clientHeight;
intW = document.body.clientWidth;
} return { width: parseInt(intW), height: parseInt(intH) };
} function setLayerPosition() {
var shadow = document.getElementById('shadow');
var question = document.getElementById('question'); var bws = getBrowserHeight();
shadow.style.width = bws.width + 'px';
shadow.style.height = bws.height + 'px'; question.style.left = parseInt((bws.width - 350) / 2);
question.style.top = parseInt((bws.height - 200) / 2); shadow = null;
question = null;
} function showLayer() {
setLayerPosition(); var shadow = document.getElementById('shadow');
var question = document.getElementById('question');
shadow.style.display = 'block';
question.style.display = 'block'; shadow = null;
question = null;
}
function hideLayer() {
var shadow = document.getElementById('shadow');
var question = document.getElementById('question');
shadow.style.display = 'none';
question.style.display = 'none'; shadow = null;
question = null;
} window.onresize = setLayerPosition;
</script>
</head>
<body>
<div id="shadow" class="opaqueLayer"> </div>
<div id="question" class="questionLayer">
<br />
<br />
<br />
We can put anything in here
<br />
<br />
<br />
<input type="button" onclick="hideLayer();" value="Close" />
</div>
<h3>Modal Layer Test</h3>
<p>Click the image below to display the "modal" layer</p>
<img src="http://www.google.com/intl/en_ALL/images/logo.gif" alt="Test Image" onclick="showLayer();" />
</body>
</html>
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.height = iTree_Alert_pageHeight + "px";
var sClientWidth = document.documentElement.clientWidth;
var sWidth = document.body.clientWidth;
if(sWidth < sClientWidth)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sClientWidth + "px";
iTree_Alert_MoveMaxWidth = sClientWidth - 398 + "px";
}
else if(sWidth == sClientWidth)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sClientWidth + "px";
iTree_Alert_scrollwidth = parseInt(document.documentElement.offsetWidth) - parseInt(document.body.clientWidth) + "px";
iTree_Alert_MoveMaxWidth = parseInt(document.documentElement.offsetWidth) - iTree_Alert_scrollwidth - 398 + "px";
}
else
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sWidth + "px";
iTree_Alert_MoveMaxWidth = parseInt(sWidth)- 398 + "px";
}再比如:
function TreeAlertMsgmoveStart(oEvent)
{
if(!oEvent) oEvent = window.event另外。CSS里面不能写js代码的
writer.WriteLine(" .TreeAlertMsgHeadTableCss {");
writer.WriteLine(" -moz-user-select:none; ");
writer.WriteLine(" }");另外,生成的代码最好换行
writer.WriteLine或者 writer.Write("<style type='text/css'>" + Environment.NewLine); 而不是writer.Write下面是不同浏览工作的拖放代码。学学别人怎么写的<html>
<head>
<title> Drag Demo 1 </title>
<style type="text/css">
<!--
#drag{
width:100px;
height:20px;
background-color:#eee;
border:1px solid #333;
position:absolute;
top:30px;
left:200px;
text-align:center;
cursor:default;
}
//-->
</style>
<script type="text/javascript">
<!--
window.onload=function(){
drag(document.getElementById('drag'));
};function drag(o){
o.onmousedown=function(a){
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove=function(a){
if(!a)a=window.event;
if(!a.pageX)a.pageX=a.clientX;
if(!a.pageY)a.pageY=a.clientY;
var tx=a.pageX-x,ty=a.pageY-y;
o.style.left=tx;
o.style.top=ty;
}; d.onmouseup=function(){
if(o.releaseCapture)
o.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=null;
d.onmouseup=null;
};
};
}
//-->
</script>
</head><body>
<div id="drag">drag me<div>
</body>
</html>
<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="zn"><HEAD><TITLE>浮动层居中的对话框效果演示</TITLE>
<META http-equiv=content-type content="application/xhtml+xml; charset=gb2312">
<STYLE type=text/css>HTML {
HEIGHT: 100%
}
BODY {
HEIGHT: 100%
}
BODY {
FONT-SIZE: 14px; FONT-FAMILY: Tahoma, Verdana, sans-serif
}
DIV.neat-dialog-cont {
Z-INDEX: 98; BACKGROUND: none transparent scroll repeat 0% 0%; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%
}
DIV.neat-dialog-bg {
Z-INDEX: -1; FILTER: alpha(opacity=70); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: #eee; opacity: 0.7
}
DIV.neat-dialog {
BORDER-RIGHT: #444 1px solid; BORDER-TOP: #444 1px solid; Z-INDEX: 99; MARGIN-LEFT: auto; BORDER-LEFT: #444 1px solid; WIDTH: 30%; MARGIN-RIGHT: auto; BORDER-BOTTOM: #444 1px solid; POSITION: relative; TOP: 25%; BACKGROUND-COLOR: #fff
}
DIV.neat-dialog-title {
PADDING-RIGHT: 0.3em; PADDING-LEFT: 0.3em; FONT-SIZE: 0.8em; PADDING-BOTTOM: 0.1em; MARGIN: 0px; LINE-HEIGHT: 1.2em; PADDING-TOP: 0.1em; BORDER-BOTTOM: #444 1px solid; POSITION: relative
}
IMG.nd-cancel {
RIGHT: 0.2em; POSITION: absolute; TOP: 0.2em
}
DIV.neat-dialog P {
PADDING-RIGHT: 0.2em; PADDING-LEFT: 0.2em; PADDING-BOTTOM: 0.2em; PADDING-TOP: 0.2em; TEXT-ALIGN: center
}
</STYLE><SCRIPT type=text/javascript>
function NeatDialog(sHTML, sTitle, bCancel)
{
window.neatDialog = null;
this.elt = null;
if (document.createElement && document.getElementById)
{
var dg = document.createElement("div");
dg.className = "neat-dialog";
if (sTitle)
sHTML = '<div class="neat-dialog-title">'+sTitle+
((bCancel)?
'<img src="x.gif" alt="Cancel" class="nd-cancel" />':'')+
'</div>\n' + sHTML;
dg.innerHTML = sHTML; var dbg = document.createElement("div");
dbg.id = "nd-bdg";
dbg.className = "neat-dialog-bg"; var dgc = document.createElement("div");
dgc.className = "neat-dialog-cont";
dgc.appendChild(dbg);
dgc.appendChild(dg); //adjust positioning if body has a margin
if (document.body.offsetLeft > 0)
dgc.style.marginLeft = document.body.offsetLeft + "px"; document.body.appendChild(dgc);
if (bCancel) document.getElementById("nd-cancel").onclick = function()
{
window.neatDialog.close();
};
this.elt = dgc;
window.neatDialog = this;
}
}
NeatDialog.prototype.close = function()
{
if (this.elt)
{
this.elt.style.display = "none";
this.elt.parentNode.removeChild(this.elt);
}
window.neatDialog = null;
}function openDialog()
{var sHTML = '<p>阿里西西WEB开发脚本特效集演示中心,阿里西西<a href="http://www.alixixi.com">www.alixixi.com</a>国内最大的WEB开发资源社区!</p>'+
'<p><button onclick="window.neatDialog.close()">关闭!</button></p>';
new NeatDialog(sHTML, "欢迎光临!", false);
}
</SCRIPT><META content="MSHTML 6.00.6000.16544" name=GENERATOR></HEAD>
<BODY>
<H1>浮动层居中的对话框效果演示</H1><BUTTON onclick=openDialog()>演示层提示效果</BUTTON></BODY></HTML>
var iTree_Alert_MoveMaxHeight=0;
var iTree_Alert_MoveMaxWidth=0;
var iTree_Alert_scrolltop = 0;
var iTree_Alert_scrollleft = 0;
var iTree_Alert_pageHeight = 0;
var iTree_Alert_scrollwidth=0;///////pageloadshowMsg
window.onload = function ()
{
iTree_Alert_pageHeight=document.body.clientHeight;
iTree_Alert_pageHeight = document.documentElement.clientHeight>iTree_Alert_pageHeight?document.documentElement.clientHeight: iTree_Alert_pageHeight;
if(TreeAlertMsg$('TreeOverlayBackgroundDiv')['style']['display']=="block")
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.top=0;
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.height = iTree_Alert_pageHeight + "px";
iTree_Alert_MoveMaxHeight = iTree_Alert_pageHeight - parseInt(TreeAlertMsg$('TreeAlertMsgDiv').offsetHeight);
var sClientWidth = document.documentElement.clientWidth;
var sWidth = document.body.clientWidth;
if(sClientWidth < sWidth)
{
iTree_Alert_scrollwidth = parseInt(document.documentElement.scrollWidth) - parseInt(document.body.clientWidth);
iTree_Alert_MoveMaxWidth = parseInt(sWidth) - iTree_Alert_scrollwidth - parseInt(TreeAlertMsg$('TreeAlertMsgDiv').offsetWidth);
}
else if(sClientWidth == sWidth)
{
iTree_Alert_MoveMaxWidth = parseInt(document.documentElement.offsetWidth) - iTree_Alert_scrollwidth - parseInt(TreeAlertMsg$('TreeAlertMsgDiv').offsetWidth);
}
}
}
/*ShowPage*/
function TreeAlertMsgShowMsg(_sMsg)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.height = iTree_Alert_pageHeight + "px";
var sClientWidth = document.documentElement.clientWidth;
var sWidth = document.body.clientWidth;
if(sWidth < sClientWidth)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sClientWidth + "px";
iTree_Alert_MoveMaxWidth = sClientWidth - 398 + "px";
}
else if(sWidth == sClientWidth)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sClientWidth + "px";
iTree_Alert_scrollwidth = parseInt(document.documentElement.offsetWidth) - parseInt(document.body.clientWidth) + "px";
iTree_Alert_MoveMaxWidth = parseInt(document.documentElement.offsetWidth) - iTree_Alert_scrollwidth - 398 + "px";
}
else
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sWidth + "px";
iTree_Alert_MoveMaxWidth = parseInt(sWidth)- 398 + "px";
}
TreeAlertMsg$('TreeAlertMsgTable_Table_MsgTd').innerText = _sMsg;
var selectControls = document.getElementsByTagName("select");
for(var i=0;i<selectControls.length;i++)
{
selectControls[i]['style']['visibility']="hidden";
} TreeAlertMsg$('TreeOverlayBackgroundDiv')['style']['display']="block";
TreeAlertMsg$('TreeAlertMsgDiv')['style']['display']="block";
TreeAlertMsgmiddle("TreeAlertMsgDiv");
iTree_Alert_scrolltop = parseInt(document.body.scrollTop);
iTree_Alert_scrollleft = parseInt(document.body.scrollLeft);
}/*HiddenMsg*/
function TreeAlertMsgHiddenMsg()
{
TreeAlertMsg$('TreeOverlayBackgroundDiv')['style']['display']="none";
TreeAlertMsg$('TreeAlertMsgDiv')['style']['display']="none";
window.onscroll = null;
var selectControls = document.getElementsByTagName("select");
for(var i=0;i<selectControls.length;i++)
{
selectControls[i]['style']['visibility']="visible";
}
}
function TreeAlertMsgOnscroll()
{
var t = document.body.scrollTop;
var l = document.body.scrollLeft;
var oAlertMsgDiv = TreeAlertMsg$('TreeAlertMsgDiv');
oAlertMsgDiv.style.top = parseInt(oAlertMsgDiv.style.top) + (t - iTree_Alert_scrolltop) + "px";
oAlertMsgDiv.style.left = parseInt(oAlertMsgDiv.style.top) + (l - iTree_Alert_scrollleft) + "px";
}/*Msgmiddle*/
function TreeAlertMsgmiddle(_sId)
{
var sClientWidth = document.documentElement.clientWidth;
var sClientHeight = document.documentElement.clientHeight;
var sScrollTop = document.documentElement.scrollTop;
TreeAlertMsg$(_sId)['style']['position'] = "absolute";
TreeAlertMsg$(_sId)['style']['left'] = (document.documentElement.clientWidth / 2) - 398/2 + "px";
var sTop = (sClientHeight / 2) - 206 / 2;
TreeAlertMsg$(_sId)['style']['top'] = sTop > 0 ? sTop + "px" : (sClientHeight / 2 + sScrollTop) - 206 / 2 + "px";
}/*GetObject*/
function TreeAlertMsg$(_sId)
{
var oControls = document.getElementById(_sId);
return oControls
}/*windowSizeChange*/
window.onresize=function TreeAlertMsgSize()
{
if(TreeAlertMsg$('TreeOverlayBackgroundDiv')['style']['display']=="block")
{
var oTreeAlertMsg = TreeAlertMsg$("TreeAlertMsgDiv");
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.height = iTree_Alert_pageHeight + "px";
iTree_Alert_MoveMaxHeight = iTree_Alert_pageHeight - parseInt(oTreeAlertMsg.offsetHeight) + "px";
var sClientWidth = document.documentElement.clientWidth;
var sWidth = document.body.clientWidth;
if(sWidth < sClientWidth)
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sClientWidth + "px";
iTree_Alert_MoveMaxWidth = sClientWidth - parseInt(oTreeAlertMsg.offsetWidth) + "px";
}
else
{
TreeAlertMsg$('TreeOverlayBackgroundDiv').style.width = sWidth-iTree_Alert_scrollwidth + "px";
iTree_Alert_MoveMaxWidth = sWidth-iTree_Alert_scrollwidth - parseInt(oTreeAlertMsg.offsetWidth) + "px";
}
TreeAlertMsgmiddle('TreeAlertMsgDiv');
}
}var iTree_Alert_excursionX = 0;
var iTree_Alert_excursionY = 0;
/*MoveTreeAlertMsg*/
function TreeAlertMsgmoveStart(oEvent)
{
if(!oEvent) oEvent = window.event
var oTreeAlertMsg = TreeAlertMsg$('TreeAlertMsgDiv');
var oTreeAlertMsgTop = TreeAlertMsg$('TreeAlertMsgDiv').style.top;
var oTreeAlertMsgLeft = TreeAlertMsg$('TreeAlertMsgDiv').style.left;
var tempx = oEvent.clientX + document.body.scrollLeft;
var tempy = oEvent.clientY + document.body.scrollTop;
iTree_Alert_excursionX = parseInt(tempx) - parseInt(oTreeAlertMsgLeft);
iTree_Alert_excursionY = parseInt(tempy) - parseInt(oTreeAlertMsgTop);
if(oTreeAlertMsg.setCapture)
oTreeAlertMsg.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); oTreeAlertMsg.onmousemove = TreeAlertMsgmousemove;
oTreeAlertMsg.onmouseup = TreeAlertMsgMouseup;
}function TreeAlertMsgmousemove(oEvent)
{ if(!oEvent) oEvent = window.event
var tempmousex = oEvent.clientX + document.body.scrollLeft;
var tempmousey = oEvent.clientY + document.body.scrollTop;
TreeAlertMsg$("TreeAlertMsgDiv").style.top = parseInt(tempmousey) - iTree_Alert_excursionY + "px";
TreeAlertMsg$("TreeAlertMsgDiv").style.left = parseInt(tempmousex) - iTree_Alert_excursionX + "px";
}
function TreeAlertMsgMouseup(oEvent)
{
var oTreeAlertMsg = TreeAlertMsg$("TreeAlertMsgDiv");
var iAlertMsgTop = parseInt(oTreeAlertMsg.style.top);
var iAlertMsgLeft = parseInt(oTreeAlertMsg.style.left);
if(iAlertMsgTop < 0)
{
oTreeAlertMsg.style.top = 0;
}
else if(iAlertMsgTop > iTree_Alert_MoveMaxHeight-2)
{
oTreeAlertMsg.style.top = iTree_Alert_MoveMaxHeight-2 + "px";
}
if(iAlertMsgLeft < 0 )
{
oTreeAlertMsg.style.left = 0;
}
else if(iAlertMsgLeft > iTree_Alert_MoveMaxWidth)
{
oTreeAlertMsg.style.left = iTree_Alert_MoveMaxWidth + "px";
}
if(oTreeAlertMsg.releaseCapture)
oTreeAlertMsg.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
oTreeAlertMsg.onmousemove = null;
oTreeAlertMsg.onmouseup = null;
}
writer.WriteLine("<style type='text/css'>");
writer.WriteLine(" .TreeAlertMsgbt_mouseout {" );
writer.WriteLine(" BORDER-RIGHT: #2C59AA 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #2C59AA 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5); BORDER-LEFT: #2C59AA 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #2C59AA 1px solid;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgbt_mouseover {");
writer.WriteLine(" BORDER-RIGHT: #2C59AA 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #2C59AA 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#D7E7FA); BORDER-LEFT: #2C59AA 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #2C59AA 1px solid;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgbt_mousedown {");
writer.WriteLine(" BORDER-RIGHT: #FFE400 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #FFE400 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5); BORDER-LEFT: #FFE400 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #FFE400 1px solid;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgbt_mouseup {");
writer.WriteLine(" BORDER-RIGHT: #2C59AA 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #2C59AA 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 12px; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5); BORDER-LEFT: #2C59AA 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #2C59AA 1px solid;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeOverlayBackgroundDivCss {");
writer.WriteLine(" display: none;position: absolute; top: 0px; margin: 0px; left: 0px; background: " + sOverlayBackColor + "; z-index: " + iBackColorz_index.ToString() + ";");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgDivCss {");
writer.WriteLine(" display: none;position: absolute;width:398px;z-index: " + (iBackColorz_index + 1).ToString() + ";height:206px;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgTableCss {");
writer.WriteLine(" border: 1px solid #000000;position: absolute;");
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgHeadTdCss {");
if (sAlertMsgHeadImgUrl == string.Empty)
{
writer.WriteLine(" background: url(" + this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "TreeControls.App_Themes.tit_dialog.gif") + ") repeat-x;");
}
else
{
writer.WriteLine(" background: url(" + sAlertMsgHeadImgUrl + ") repeat-x;");
}
writer.WriteLine(" }");
writer.WriteLine(" .TreeAlertMsgHeadTableCss {");
writer.WriteLine(" -moz-user-select:none; ");
writer.WriteLine(" }");
writer.WriteLine("</style>");
以上代码在IE7,Firefox 2,Netscape 9.0上测试通过