ListBox的双击事件与弹出窗口
//---------------------------------------------------------
function winopen(obj,winname,width,height,left,top,resizable,scrollbars){
return window.open(obj.href,winname,"width="+width+",height="+height+",left="+left+",top="+top+",resizable="+resizable+",scrollbars="+scrollbars);
}
function check(){
var e = run();
if(!e||(e.closed||!e.focus)){
alert('弹出窗口被拦截器拦截了,请尝试关闭它,以便正常浏览本站!');
}
}
//------------以下方法可能不会被IE拦截---------------
string strJS = GetScript();
Page.RegisterClientScriptBlock("OpenPage",strJS);
//为listbox添加双击事件
listboxSupperName.Attributes.Add("ondblclick",JudgeBoxCont("OutUser"));
/**//// <summary>
/// 功能描述:向页面提交js文件 不许变动直接粘贴
/// </summary>
/// <returns></returns>
private string GetScript()
{
StringBuilder sbJS = new StringBuilder();
sbJS.Append("<script Language='javascript'>");
sbJS.Append("window._open=window.open;");
sbJS.Append("window.open=window_new_open;");
sbJS.Append("function window_new_open( a,b,c ){");
sbJS.Append("var win;");
sbJS.Append("if( c ){");
sbJS.Append("win=window._open( a,b,c );}");
sbJS.Append("else if( b ){");
sbJS.Append("win=window._open( a,b );}");
sbJS.Append("else ");
sbJS.Append("win=window._open( a );");
sbJS.Append("if( win!=null&&!win.closed )");
sbJS.Append("return win;");
sbJS.Append("var option='status:0;help:0;dialogleft:0px;dialogtop:0px;dialogheight:0px;dialog0px';");
sbJS.Append("win=showModalDialog( 'open.htm',[a,b,c],option );");
sbJS.Append("return win;}");
sbJS.Append("</script>");
string abc = sbJS.ToString();
return sbJS.ToString();
}
/**//// <summary>
/// 功能描述:判断组外隐藏变量是否为空,如果为空就不要跳转
/// 备 注:不能通过传入参数的方式实现,string strCont
/// 注 释:strValue和路径 是唯一可以修改的变量 多的话可以用switch
/// </summary>
private string JudgeBoxCont(string strValue)
{
string strInfoUser = "";
if(strValue == "OutUser")
{
strInfoUser = "document.Form1.hdOutUser.value";
}
else
{
strInfoUser = "document.Form1.hdInsidUser.value";
}
//string strValue = "document.Form1.hdOutUser.value";
StringBuilder sbJudge = new StringBuilder();
sbJudge.Append("javascript:");
sbJudge.Append("if("+ strInfoUser +" == '')return;");
sbJudge.Append("else{");
sbJudge.Append("window.open('../IRMUsers/DispUserInfo.aspx?userid='+" + strInfoUser +");}");
sbJudge.Append("if(document.Form1.lboxGroupOuterUser.value == '')document.Form1.hdOutUser.value = '';");
sbJudge.Append("if(document.Form1.lboxGroupInsideUser.value == '')document.Form1.hdInsidUser.value = '';");
return sbJudge.ToString();
}
//------------以下方法被IE拦截提示信息。。。哈哈。。---------------
可以提示一下:
var showWin = window.open('show.aspx','_blank','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=540,height=500 top=40,left=40');
if (showWin) {
showWin.focus();
} else {
alert("检测到弹出窗口阻止程序。您的 Web 浏览器必须允许该站点弹出窗口。");
return;
}
//---------------------------------------------------------
function winopen(obj,winname,width,height,left,top,resizable,scrollbars){
return window.open(obj.href,winname,"width="+width+",height="+height+",left="+left+",top="+top+",resizable="+resizable+",scrollbars="+scrollbars);
}
function check(){
var e = run();
if(!e||(e.closed||!e.focus)){
alert('弹出窗口被拦截器拦截了,请尝试关闭它,以便正常浏览本站!');
}
}
//------------以下方法可能不会被IE拦截---------------
string strJS = GetScript();
Page.RegisterClientScriptBlock("OpenPage",strJS);
//为listbox添加双击事件
listboxSupperName.Attributes.Add("ondblclick",JudgeBoxCont("OutUser"));
/**//// <summary>
/// 功能描述:向页面提交js文件 不许变动直接粘贴
/// </summary>
/// <returns></returns>
private string GetScript()
{
StringBuilder sbJS = new StringBuilder();
sbJS.Append("<script Language='javascript'>");
sbJS.Append("window._open=window.open;");
sbJS.Append("window.open=window_new_open;");
sbJS.Append("function window_new_open( a,b,c ){");
sbJS.Append("var win;");
sbJS.Append("if( c ){");
sbJS.Append("win=window._open( a,b,c );}");
sbJS.Append("else if( b ){");
sbJS.Append("win=window._open( a,b );}");
sbJS.Append("else ");
sbJS.Append("win=window._open( a );");
sbJS.Append("if( win!=null&&!win.closed )");
sbJS.Append("return win;");
sbJS.Append("var option='status:0;help:0;dialogleft:0px;dialogtop:0px;dialogheight:0px;dialog0px';");
sbJS.Append("win=showModalDialog( 'open.htm',[a,b,c],option );");
sbJS.Append("return win;}");
sbJS.Append("</script>");
string abc = sbJS.ToString();
return sbJS.ToString();
}
/**//// <summary>
/// 功能描述:判断组外隐藏变量是否为空,如果为空就不要跳转
/// 备 注:不能通过传入参数的方式实现,string strCont
/// 注 释:strValue和路径 是唯一可以修改的变量 多的话可以用switch
/// </summary>
private string JudgeBoxCont(string strValue)
{
string strInfoUser = "";
if(strValue == "OutUser")
{
strInfoUser = "document.Form1.hdOutUser.value";
}
else
{
strInfoUser = "document.Form1.hdInsidUser.value";
}
//string strValue = "document.Form1.hdOutUser.value";
StringBuilder sbJudge = new StringBuilder();
sbJudge.Append("javascript:");
sbJudge.Append("if("+ strInfoUser +" == '')return;");
sbJudge.Append("else{");
sbJudge.Append("window.open('../IRMUsers/DispUserInfo.aspx?userid='+" + strInfoUser +");}");
sbJudge.Append("if(document.Form1.lboxGroupOuterUser.value == '')document.Form1.hdOutUser.value = '';");
sbJudge.Append("if(document.Form1.lboxGroupInsideUser.value == '')document.Form1.hdInsidUser.value = '';");
return sbJudge.ToString();
}
//------------以下方法被IE拦截提示信息。。。哈哈。。---------------
可以提示一下:
var showWin = window.open('show.aspx','_blank','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=540,height=500 top=40,left=40');
if (showWin) {
showWin.focus();
} else {
alert("检测到弹出窗口阻止程序。您的 Web 浏览器必须允许该站点弹出窗口。");
return;
}