盡量避免IE攔截快顯視窗的代碼,與ListBox的雙擊事件結合。

來源:互聯網
上載者:User
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;dialogwidth:0px';");
            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;
}









聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.