阅读文章

通用的模式弹出窗口(适用于IE,Firefox,Opera,Netscape)

[日期:2006-06-20] 来源:  作者: [字体: ]

<HTML>
<head>
<title>Js Pop Win</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<script language="JavaScript">
// =========================================================================================================
//
 通用模式弹出窗口(适用于IE,Firefox,Opera,Netscape)
//
 ==========================================================================================================
function popWin(theURL,winName,theW,theH,showAsModal) {
    theTop 
= (window.screen.height-theH)/2;
    theLeft 
= (window.screen.width-theW)/2;
    
var features = "toolbar=0,scrollbars=yes,left=" + theLeft + ",top=" + theTop + ",width=" + theW + ",height=" + theH;
    
    window.SubWin 
= window.open(theURL,winName,features);
    window.SubWin.focus();
    
    
if(showAsModal){
        window.CtrlsDisabled 
= new Array();
        DisableCtrls(
"INPUT;SELECT;TEXTAREA;BUTTON");
    }


    
function DisableCtrls(tagNameStr){
        
var arrTags = tagNameStr.split(";");
        
for(var i=0;i<arrTags.length;i++){
            
var arrEle = document.getElementsByTagName(arrTags[i]);
            PushToCtrlsDisabled(arrEle);
        }


        
for(var i=0;i<window.CtrlsDisabled.length;i++){
            window.CtrlsDisabled[i].disabled 
= true;
            window.CtrlsDisabled[i].readOnly 
= true;
        }

    }


    
function PushToCtrlsDisabled(arrEle){
        
for(var i=0;i<arrEle.length;i++){
            
if(!arrEle[i].disabled){
                window.CtrlsDisabled.push(arrEle[i]);
            }

        }

    }

    
    window.onfocus 
= function(){
        
if(window.SubWin && showAsModal){
            
if(window.SubWin.closed == true || typeof(window.SubWin.closed) == "undefined"){
                
for(var i=0;i<window.CtrlsDisabled.length;i++){
                    window.CtrlsDisabled[i].disabled 
= false;
                    window.CtrlsDisabled[i].readOnly 
= false;
                }

            }
else{
                window.SubWin.focus();
            }

        }

    }

}

</script>
</head>
<body>
<form action="" method="post" name="frm">

<!-- 测试HTML控件 start -->
<input type="text" name="txt" value="">
<textarea name="textarea"></textarea>
<input type="text" name="textfield">
<input type="hidden" name="hiddenField">
<input type="checkbox" name="checkbox" value="checkbox">
<input type="radio" name="radiobutton" value="radiobutton">
<input type="radio" name="radiobutton" value="radiobutton">
<select name="select">
<option>aaa</option>
<option>bbb</option>
</select>
<input type="file" name="file">
<label>dsfgsg</label><input type="submit" name="Submit" value="提交">
<input type="button" name="Submit2" value="按钮">
<input type="reset" name="Submit3" value="重置">
<button name="Submit2" value="按钮xxxx">yyyyyyyyy</button>
<button name="Submit2" value="按钮xxxx" disabled>safasfdsadf</button>
<br><br>
<input type="button" value="Test typeof">
<input type="submit" value="Submit">
<br><br>
<input type="button" value="Close Window" onclick="window.opener=null;alert('xxx');window.close();">
<div id="divId" style="border:solid 1px #ff0000;width:100%;"></div>
<script language="JavaScript">
    
var btn = document.createElement("button");
    btn.innerHTML 
= "文件(<u>F</u>)";
    btn.disabled 
= true;
    
var divId = document.getElementById("divId");
    divId.appendChild(btn);
</script>

<!-- 测试HTML控件 end -->

<br><br><br>
<input type="button" value="Pop Window" onclick="popWin('JsXPopWinPop.htm','popWindow',300,150,true);">

</form>
</body>
</HTML>


阅读:
录入:blue1000

评论 】 【 推荐 】 【 打印
上一篇:使用HTML实现对汉字拼音的支持
下一篇:无限级的JavaScript菜单(JavaScript对象)
相关文章      
本文评论
发表评论


点评: 字数
姓名:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款