asp.net里调用JS对话框的标题栏里怎样显示中文 在asp.net里调用JS语句window.alert("有数据为空!")来显示对话框,但是美中不足的是对话框最上面标题栏里都显示“Mirosoft Internet Explorer”,怎样才能显示成我需要的字符,比如“提示信息”? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不用ie的对话框,自己用个div来模拟可以自己做,或者用jquery现成的都行。 window.alert=function(title) { execScript( 'MsgBox",0, " '+title+ ' " ', 'VBScript '); } alert( "标题 ", "内容 "); 自己用div显示一个吧function MessageBox() { this.titleheight = "21"; // 提示窗口标题高度 this.bordercolor = "#666699"; // 提示窗口的边框颜色 this.titlecolor = "#1259a4"; // 提示窗口的标题颜色 this.titlebgcolor = "#e4f1fb"; // 提示窗口的标题背景色 this.bgcolor = "#FFFFFF"; // 提示内容的背景色 this.MsgAlign="left"; this.Show=function(title, msg, framesrc, w, h) { var iWidth = document.documentElement.clientWidth; var iHeight = document.documentElement.clientHeight+document.documentElement.scrollTop*2; var bgObj = document.createElement("div"); bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;"; document.body.appendChild(bgObj); var msgObj=document.createElement("div"); msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+this.bordercolor+";background-color:"+this.bgcolor+";padding:1px;line-height:22px;z-index:102;"; document.body.appendChild(msgObj); var table = document.createElement("table"); msgObj.appendChild(table); table.style.cssText = "margin:0px;border:0px;padding:0px;"; table.cellSpacing = 0; var tr = table.insertRow(-1); var titleBar = tr.insertCell(-1); titleBar.style.cssText = ";width:"+(w-84)+"px;height:"+this.titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+this.titlecolor+";cursor:move;background-color:" + this.titlebgcolor; titleBar.style.paddingLeft = "10px"; titleBar.innerHTML = title; var moveX = 0; var moveY = 0; var moveTop = 0; var moveLeft = 0; var moveable = false; var docMouseMoveEvent = document.onmousemove; var docMouseUpEvent = document.onmouseup; titleBar.onmousedown = function(){ var evt = getEvent(); moveable = true; moveX = evt.clientX; moveY = evt.clientY; moveTop = parseInt(msgObj.style.top); moveLeft = parseInt(msgObj.style.left); document.onmousemove = function(){ if (moveable) { var evt = getEvent(); var x = moveLeft + evt.clientX - moveX; var y = moveTop + evt.clientY - moveY; if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) { msgObj.style.left = x + "px"; msgObj.style.top = y + "px"; } } }; document.onmouseup = function (){ if (moveable) { document.onmousemove = docMouseMoveEvent; document.onmouseup = docMouseUpEvent; moveable = false; moveX = 0; moveY = 0; moveTop = 0; moveLeft = 0; } }; } var closeBtn = tr.insertCell(-1); closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + this.titlebgcolor; closeBtn.innerHTML = "<span style="font-size:10pt;color:"+this.titlecolor+";" style="font-size:10pt;color:"+this.titlecolor+";" id='closeBtn'>×关闭窗口"; closeBtn.onclick = function(){ document.body.removeChild(bgObj); document.body.removeChild(msgObj); } var msgBox = table.insertRow(-1).insertCell(-1); msgBox.style.cssText = "font:10pt '宋体';"; msgBox.colSpan = 2; if(framesrc != "") { msg = "<iframe name='frmAlertWin' id='frmAlertWin' src="about:blank" src="about:blank" frameborder=0 marginwidth=0 marginheight=0 style='height:"+(h-this.titleheight-10)+"px;width:100%;'></iframe>"; } msgBox.innerHTML = "<div style="\" style="\""text-align:"+this.MsgAlign+";\">"+msg+"</div>"; if(document.getElementById("frmAlertWin") != null) { document.getElementById("frmAlertWin").src = framesrc; } function getEvent(){ return window.event || arguments.callee.caller.arguments[0]; } } }调用方式 var msgbox=new MessageBox(); msgbox.Show('站内公告',"小小提示","",500,220);///参数:标题,内容(提示为连接页面时可为空),连接页面地址(使用文字是可为空),宽度,高度 要注意的是如果在页面加载时就要弹出提示 请将调用代码放在body标记以后 否则在IE8下回出现错误 <a href="javascript:<%=ss()%>">高手进来看看</a> ajax 下拉菜单 修改csproj的编译脚本,是否可以实现VSS的签入和签出 aspx类型的网页传到空间里,浏览的时候有错? 像msdn这种文档帮助系统(b/s)是如何开发的?要有搜索,随时添加资料等功能~ 数据库架设方案求助,请大侠来一起研究!!! 一个查询的老问题 如何用在cs代码中弹出_blank类型的窗口 怎样用visuio.Net调试单独一个cs文件 wpf中word文件转xps文件报转换后的xps文件路径找不到 关于winform操作excel 正则表达式判断是否含有汉字
不用ie的对话框,自己用个div来模拟
可以自己做,或者用jquery现成的都行。
{
execScript( 'MsgBox",0, " '+title+ ' " ', 'VBScript ');
}
alert( "标题 ", "内容 ");
function MessageBox()
{
this.titleheight = "21"; // 提示窗口标题高度
this.bordercolor = "#666699"; // 提示窗口的边框颜色
this.titlecolor = "#1259a4"; // 提示窗口的标题颜色
this.titlebgcolor = "#e4f1fb"; // 提示窗口的标题背景色
this.bgcolor = "#FFFFFF"; // 提示内容的背景色
this.MsgAlign="left"; this.Show=function(title, msg, framesrc, w, h)
{
var iWidth = document.documentElement.clientWidth;
var iHeight = document.documentElement.clientHeight+document.documentElement.scrollTop*2;
var bgObj = document.createElement("div");
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
document.body.appendChild(bgObj); var msgObj=document.createElement("div");
msgObj.style.cssText = "position:absolute;font:11px '宋体';top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid "+this.bordercolor+";background-color:"+this.bgcolor+";padding:1px;line-height:22px;z-index:102;";
document.body.appendChild(msgObj); var table = document.createElement("table");
msgObj.appendChild(table);
table.style.cssText = "margin:0px;border:0px;padding:0px;";
table.cellSpacing = 0;
var tr = table.insertRow(-1);
var titleBar = tr.insertCell(-1);
titleBar.style.cssText = ";width:"+(w-84)+"px;height:"+this.titleheight+"px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:"+this.titlecolor+";cursor:move;background-color:" + this.titlebgcolor;
titleBar.style.paddingLeft = "10px";
titleBar.innerHTML = title;
var moveX = 0;
var moveY = 0;
var moveTop = 0;
var moveLeft = 0;
var moveable = false;
var docMouseMoveEvent = document.onmousemove;
var docMouseUpEvent = document.onmouseup; titleBar.onmousedown = function(){
var evt = getEvent();
moveable = true;
moveX = evt.clientX;
moveY = evt.clientY;
moveTop = parseInt(msgObj.style.top);
moveLeft = parseInt(msgObj.style.left); document.onmousemove = function(){
if (moveable)
{
var evt = getEvent();
var x = moveLeft + evt.clientX - moveX;
var y = moveTop + evt.clientY - moveY;
if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) )
{
msgObj.style.left = x + "px";
msgObj.style.top = y + "px";
}
}
}; document.onmouseup = function (){
if (moveable)
{
document.onmousemove = docMouseMoveEvent;
document.onmouseup = docMouseUpEvent;
moveable = false;
moveX = 0;
moveY = 0;
moveTop = 0;
moveLeft = 0;
}
};
} var closeBtn = tr.insertCell(-1);
closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + this.titlebgcolor;
closeBtn.innerHTML = "<span style="font-size:10pt;color:"+this.titlecolor+";" style="font-size:10pt;color:"+this.titlecolor+";" id='closeBtn'>×关闭窗口";
closeBtn.onclick = function(){
document.body.removeChild(bgObj);
document.body.removeChild(msgObj);
}
var msgBox = table.insertRow(-1).insertCell(-1);
msgBox.style.cssText = "font:10pt '宋体';";
msgBox.colSpan = 2; if(framesrc != "")
{
msg = "<iframe name='frmAlertWin' id='frmAlertWin' src="about:blank" src="about:blank" frameborder=0 marginwidth=0 marginheight=0 style='height:"+(h-this.titleheight-10)+"px;width:100%;'></iframe>";
}
msgBox.innerHTML = "<div style="\" style="\""text-align:"+this.MsgAlign+";\">"+msg+"</div>"; if(document.getElementById("frmAlertWin") != null)
{
document.getElementById("frmAlertWin").src = framesrc;
}
function getEvent(){
return window.event || arguments.callee.caller.arguments[0];
}
}
}
调用方式
var msgbox=new MessageBox();
msgbox.Show('站内公告',"小小提示","",500,220);///参数:标题,内容(提示为连接页面时可为空),连接页面地址(使用文字是可为空),宽度,高度
要注意的是如果在页面加载时就要弹出提示 请将调用代码放在body标记以后 否则在IE8下回出现错误