通用的模式弹出窗口
<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>
通用的模式弹出窗口(适用于IE,Firefox,Opera,Netscape)
<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>