我不知道下面的xWin对象为什么我注释掉的两个document.body.appendChild会报错,报错内容是无法打开internet站点,但是我把这两行注释掉以后就不会报这个错,但是也没办法用了,请高手帮忙看下谢谢
var oWins = [];
var BUTTONSPACE = 5;
var BUTTONSTARTRIGHT = 10;
//var SYSWINDEFAULTWIDTH = 300;
//var SYSWINDEFAULTHEIGHT = 150;
var xWin_styles = {
win_ifrm:"syswinBar_mask_iframe",
win:"syswinBar",
win_fix:"syswinBar_fix",
win_head:"syswinBar_head",
win_body:"syswinBar_body",
win_foot:"syswinBar_foot",
win_closeButton:"close",
win_buttongroup:"syswinBar_buttongroup",
win_button:"btn-common size6"
};
function xWin(title,width,height,panel,closeButton,styles,onok,oncancel,oncleanup){
this.title = title;
this.width = width == null ? "" : width;
this.height = height == null ? "" : height;
this.panel = panel == null ? "" : $(panel).innerHTML;
if(panel != null) $(panel).innerHTML = "";
this.closeButton = closeButton;
this.styles = styles;
this.onok = onok == null ? function(){} : onok;
this.oncancel = oncancel == null ? function(){} : oncancel;
this.oncleanup = oncleanup == null ? function(){} : oncleanup;
var oWin;
var oWin_fix;
var oWin_head;
var oWin_head_mask;
var oWin_body;
var oWin_foot;
var oTitle;
var oCloseButton; var oButtonGroup;
var oOk;
var oCancel;
var oCleanup;
var oIframe; this.createToObj = function(){
oIframe = document.createElement('iframe');
oIframe.className = this.styles.win_ifrm;
oIframe.frameBorder = "no";
oIframe.scrolling = "no";
//document.body.appendChild(oIframe);
oIframe.style.display = "none";
oWin = document.createElement('div');
oWin_fix = document.createElement('div');
oWin_head = document.createElement('div');
oWin_head_mask = document.createElement('div');
oWin_head_mask.style.background = "#fff";
oWin_head_mask.style.position = "absolute";
if(CommonFunctions._isIE){
oWin_head_mask.style.filter = "alpha(opacity=0)";
}else{
oWin_head_mask.style.opacity = ".0";
}
oWin_head.appendChild(oWin_head_mask);
oWin_body = document.createElement('div');
oWin_foot = document.createElement('div');
oTitle = document.createElement('span'); oButtonGroup = document.createElement('div');
if(onok){
oOk = document.createElement('input');
oOk.className = this.styles.win_button;
oOk.type = "button";
oOk.value = "确定";
oOk.onclick = function(){this.onok();this.hide();}.bind(this)
oButtonGroup.appendChild(oOk);
} if(oncleanup){
oCleanup = document.createElement('input');
oCleanup.className = this.styles.win_button;
oCleanup.type = "button";
oCleanup.value = "清空";
oCleanup.onclick = function(){this.oncleanup();this.hide();}.bind(this)
if(onok || oncancel) oButtonGroup.appendChild(document.createTextNode(" "));
oButtonGroup.appendChild(oCleanup);
}
if(oncancel){
oCancel = document.createElement('input');
oCancel.className = this.styles.win_button;
oCancel.type = "button";
oCancel.value = "取消";
oCancel.onclick = function(){this.oncancel();this.hide();}.bind(this)
if(onok) oButtonGroup.appendChild(document.createTextNode(" "));
oButtonGroup.appendChild(oCancel);
}
oTitle.innerHTML = this.title;
oWin.className = this.styles.win;
oWin_fix.className = this.styles.win_fix;
oWin_head.className = this.styles.win_head;
oWin_body.className = this.styles.win_body;
oWin_body.innerHTML = this.panel;
oWin_foot.className = this.styles.win_foot;
oButtonGroup.className = this.styles.win_buttongroup;
oWin.style.width = this.width != "" ? this.width + "px" : "auto";
oWin.style.height = this.height != "" ? this.height + "px" : "auto"; oWin_head.appendChild(oTitle);
oWin_body.appendChild(oButtonGroup);
var buttons = [];
if(this.closeButton){
oCloseButton = document.createElement('a');
oCloseButton.href = "javascript:void(0)";
oCloseButton.className = this.styles.win_closeButton;
oWin_head.appendChild(oCloseButton);
buttons.push(oCloseButton);
oCloseButton.onclick = function(){
this.hide();
}.bind(this)
} oWin_fix.appendChild(oWin_head);
oWin_fix.appendChild(oWin_body);
oWin_fix.appendChild(oWin_foot);
oWin.appendChild(oWin_fix);
//document.body.appendChild(oWin);
oWin_head_mask.style.width = oWin_head.offsetWidth + "px";
oWin_head_mask.style.height = oWin_head.offsetHeight + "px";
for(var i = 0; i < buttons.length; i++){
buttons[i].style.right = (BUTTONSPACE + buttons[i].offsetWidth) * i + BUTTONSTARTRIGHT + "px";
}
this.hide();
oWins.push(this);
}.bind(this)
this.hide = function(){
oIframe.style.display = "none";
oWin.style.display = "none";
}.bind(this)
this.show = function(left, top){
oIframe.style.width = CommonFunctions.getInnerSize()[0] + CommonFunctions.getScrollSize()[0] + "px";
oIframe.style.height = CommonFunctions.getInnerSize()[1] + CommonFunctions.getScrollSize()[1] + "px";
oIframe.style.display = "";
oWin.style.display = "";
if(typeof(left) != "undefined" && typeof(top) != "undefined"){
this.setPosition(left, top);
}else{
this.setPosition((CommonFunctions.getInnerSize()[0] - oWin.offsetWidth) / 2 + CommonFunctions.getScrollSize()[0],(CommonFunctions.getInnerSize()[1] - oWin.offsetHeight) / 2 + CommonFunctions.getScrollSize()[1]);
}
function resetWins(){
oIframe.style.width = CommonFunctions.getInnerSize()[0] + CommonFunctions.getScrollSize()[0] + "px";
oIframe.style.height = CommonFunctions.getInnerSize()[1] + CommonFunctions.getScrollSize()[1] + "px";
oWin.style.left = (CommonFunctions.getInnerSize()[0] - oWin.offsetWidth) / 2 + CommonFunctions.getScrollSize()[0] + "px";
oWin.style.top = (CommonFunctions.getInnerSize()[1] - oWin.offsetHeight) / 2 + CommonFunctions.getScrollSize()[1] + "px";
}
if(window.addEventListener){
window.addEventListener('resize', resetWins, false);
}else if(window.attachEvent){
window.attachEvent('onresize', resetWins);
}
if(window.addEventListener){
window.addEventListener('scroll', resetWins, false);
}else if(window.attachEvent){
window.attachEvent('onscroll', resetWins);
}
}.bind(this)
this.setPosition = function(x,y){
oWin.style.left = x + "px";
oWin.style.top = y + "px";
}.bind(this)
this.getPosition = function(){
var x = CommonFunctions.getAbsolutePoint(oWin).l;
var y = CommonFunctions.getAbsolutePoint(oWin).t
return {"x":x , "y":y};
}
this.return_oOk = function(){
return oOk;
}
this.return_oCancel = function(){
return oCancel;
}
this.return_oCleanup = function(){
return oCleanup;
}
}这是部分页面:
<div class="fuc"><input type="submit" name="button" id="button"
value="新 增" class="table_button" onclick="oWin2.show();" /></div>
</div>
<!-- 右侧列表结束 --></div>
<div class="b-b-r" id="b-b-r"></div>
</div>
<div class="bottom" id="Main-right-container-bottom">
<div class="c-b-l"></div>
<div class="c-b-r"></div>
</div>
</div>
<!-- 右侧容器结束 --></div>
<!-- 右侧结束 --></div>
<!-- 主体结束 -->
<div style="display: none" >
<div id="win3_panel">
<table border="0" cellpadding="0" cellspacing="0" class="formTable"> <tr>
<td class="caption">新闻图片文件(flash)</td>
<td class="content"><input type="file" name="pic" class="file" />
</td>
</tr> <tr>
<td class="caption">栏目</td>
<td class="content"><select name="select2" class="select">
<option>栏目一</option>
</select></td>
</tr></table>
</div>
</div>
<script type="text/javascript">
function oWin1_onok(){
}
function oWin1_oncancel(){
}
function oWin2_onok(){
}
function oWin2_oncancel(){
}
var oWin2 = new xWin("flash 上传",500,null,"win3_panel",true,xWin_styles,oWin2_onok,oWin2_oncancel,null);
oWin2.createToObj(document.body);
</script>
<@mteacher.footerDiv />
var oWins = [];
var BUTTONSPACE = 5;
var BUTTONSTARTRIGHT = 10;
//var SYSWINDEFAULTWIDTH = 300;
//var SYSWINDEFAULTHEIGHT = 150;
var xWin_styles = {
win_ifrm:"syswinBar_mask_iframe",
win:"syswinBar",
win_fix:"syswinBar_fix",
win_head:"syswinBar_head",
win_body:"syswinBar_body",
win_foot:"syswinBar_foot",
win_closeButton:"close",
win_buttongroup:"syswinBar_buttongroup",
win_button:"btn-common size6"
};
function xWin(title,width,height,panel,closeButton,styles,onok,oncancel,oncleanup){
this.title = title;
this.width = width == null ? "" : width;
this.height = height == null ? "" : height;
this.panel = panel == null ? "" : $(panel).innerHTML;
if(panel != null) $(panel).innerHTML = "";
this.closeButton = closeButton;
this.styles = styles;
this.onok = onok == null ? function(){} : onok;
this.oncancel = oncancel == null ? function(){} : oncancel;
this.oncleanup = oncleanup == null ? function(){} : oncleanup;
var oWin;
var oWin_fix;
var oWin_head;
var oWin_head_mask;
var oWin_body;
var oWin_foot;
var oTitle;
var oCloseButton; var oButtonGroup;
var oOk;
var oCancel;
var oCleanup;
var oIframe; this.createToObj = function(){
oIframe = document.createElement('iframe');
oIframe.className = this.styles.win_ifrm;
oIframe.frameBorder = "no";
oIframe.scrolling = "no";
//document.body.appendChild(oIframe);
oIframe.style.display = "none";
oWin = document.createElement('div');
oWin_fix = document.createElement('div');
oWin_head = document.createElement('div');
oWin_head_mask = document.createElement('div');
oWin_head_mask.style.background = "#fff";
oWin_head_mask.style.position = "absolute";
if(CommonFunctions._isIE){
oWin_head_mask.style.filter = "alpha(opacity=0)";
}else{
oWin_head_mask.style.opacity = ".0";
}
oWin_head.appendChild(oWin_head_mask);
oWin_body = document.createElement('div');
oWin_foot = document.createElement('div');
oTitle = document.createElement('span'); oButtonGroup = document.createElement('div');
if(onok){
oOk = document.createElement('input');
oOk.className = this.styles.win_button;
oOk.type = "button";
oOk.value = "确定";
oOk.onclick = function(){this.onok();this.hide();}.bind(this)
oButtonGroup.appendChild(oOk);
} if(oncleanup){
oCleanup = document.createElement('input');
oCleanup.className = this.styles.win_button;
oCleanup.type = "button";
oCleanup.value = "清空";
oCleanup.onclick = function(){this.oncleanup();this.hide();}.bind(this)
if(onok || oncancel) oButtonGroup.appendChild(document.createTextNode(" "));
oButtonGroup.appendChild(oCleanup);
}
if(oncancel){
oCancel = document.createElement('input');
oCancel.className = this.styles.win_button;
oCancel.type = "button";
oCancel.value = "取消";
oCancel.onclick = function(){this.oncancel();this.hide();}.bind(this)
if(onok) oButtonGroup.appendChild(document.createTextNode(" "));
oButtonGroup.appendChild(oCancel);
}
oTitle.innerHTML = this.title;
oWin.className = this.styles.win;
oWin_fix.className = this.styles.win_fix;
oWin_head.className = this.styles.win_head;
oWin_body.className = this.styles.win_body;
oWin_body.innerHTML = this.panel;
oWin_foot.className = this.styles.win_foot;
oButtonGroup.className = this.styles.win_buttongroup;
oWin.style.width = this.width != "" ? this.width + "px" : "auto";
oWin.style.height = this.height != "" ? this.height + "px" : "auto"; oWin_head.appendChild(oTitle);
oWin_body.appendChild(oButtonGroup);
var buttons = [];
if(this.closeButton){
oCloseButton = document.createElement('a');
oCloseButton.href = "javascript:void(0)";
oCloseButton.className = this.styles.win_closeButton;
oWin_head.appendChild(oCloseButton);
buttons.push(oCloseButton);
oCloseButton.onclick = function(){
this.hide();
}.bind(this)
} oWin_fix.appendChild(oWin_head);
oWin_fix.appendChild(oWin_body);
oWin_fix.appendChild(oWin_foot);
oWin.appendChild(oWin_fix);
//document.body.appendChild(oWin);
oWin_head_mask.style.width = oWin_head.offsetWidth + "px";
oWin_head_mask.style.height = oWin_head.offsetHeight + "px";
for(var i = 0; i < buttons.length; i++){
buttons[i].style.right = (BUTTONSPACE + buttons[i].offsetWidth) * i + BUTTONSTARTRIGHT + "px";
}
this.hide();
oWins.push(this);
}.bind(this)
this.hide = function(){
oIframe.style.display = "none";
oWin.style.display = "none";
}.bind(this)
this.show = function(left, top){
oIframe.style.width = CommonFunctions.getInnerSize()[0] + CommonFunctions.getScrollSize()[0] + "px";
oIframe.style.height = CommonFunctions.getInnerSize()[1] + CommonFunctions.getScrollSize()[1] + "px";
oIframe.style.display = "";
oWin.style.display = "";
if(typeof(left) != "undefined" && typeof(top) != "undefined"){
this.setPosition(left, top);
}else{
this.setPosition((CommonFunctions.getInnerSize()[0] - oWin.offsetWidth) / 2 + CommonFunctions.getScrollSize()[0],(CommonFunctions.getInnerSize()[1] - oWin.offsetHeight) / 2 + CommonFunctions.getScrollSize()[1]);
}
function resetWins(){
oIframe.style.width = CommonFunctions.getInnerSize()[0] + CommonFunctions.getScrollSize()[0] + "px";
oIframe.style.height = CommonFunctions.getInnerSize()[1] + CommonFunctions.getScrollSize()[1] + "px";
oWin.style.left = (CommonFunctions.getInnerSize()[0] - oWin.offsetWidth) / 2 + CommonFunctions.getScrollSize()[0] + "px";
oWin.style.top = (CommonFunctions.getInnerSize()[1] - oWin.offsetHeight) / 2 + CommonFunctions.getScrollSize()[1] + "px";
}
if(window.addEventListener){
window.addEventListener('resize', resetWins, false);
}else if(window.attachEvent){
window.attachEvent('onresize', resetWins);
}
if(window.addEventListener){
window.addEventListener('scroll', resetWins, false);
}else if(window.attachEvent){
window.attachEvent('onscroll', resetWins);
}
}.bind(this)
this.setPosition = function(x,y){
oWin.style.left = x + "px";
oWin.style.top = y + "px";
}.bind(this)
this.getPosition = function(){
var x = CommonFunctions.getAbsolutePoint(oWin).l;
var y = CommonFunctions.getAbsolutePoint(oWin).t
return {"x":x , "y":y};
}
this.return_oOk = function(){
return oOk;
}
this.return_oCancel = function(){
return oCancel;
}
this.return_oCleanup = function(){
return oCleanup;
}
}这是部分页面:
<div class="fuc"><input type="submit" name="button" id="button"
value="新 增" class="table_button" onclick="oWin2.show();" /></div>
</div>
<!-- 右侧列表结束 --></div>
<div class="b-b-r" id="b-b-r"></div>
</div>
<div class="bottom" id="Main-right-container-bottom">
<div class="c-b-l"></div>
<div class="c-b-r"></div>
</div>
</div>
<!-- 右侧容器结束 --></div>
<!-- 右侧结束 --></div>
<!-- 主体结束 -->
<div style="display: none" >
<div id="win3_panel">
<table border="0" cellpadding="0" cellspacing="0" class="formTable"> <tr>
<td class="caption">新闻图片文件(flash)</td>
<td class="content"><input type="file" name="pic" class="file" />
</td>
</tr> <tr>
<td class="caption">栏目</td>
<td class="content"><select name="select2" class="select">
<option>栏目一</option>
</select></td>
</tr></table>
</div>
</div>
<script type="text/javascript">
function oWin1_onok(){
}
function oWin1_oncancel(){
}
function oWin2_onok(){
}
function oWin2_oncancel(){
}
var oWin2 = new xWin("flash 上传",500,null,"win3_panel",true,xWin_styles,oWin2_onok,oWin2_oncancel,null);
oWin2.createToObj(document.body);
</script>
<@mteacher.footerDiv />
解决方案 »
- JS二级联动下拉菜单
- 麻烦大家帮我看一下这段代码,为什么alert不好用呢??!! 我想要做如果不输入内容就警示的操作!
- offsetTop,scrollHeight,scrollTop理解不是很清楚
- div模块移动之绝对难题。。什么原理
- js 如何实现图片放大后图片中的某个位置始终在可视区域显示
- JavaScript与服务器端交互
- AJAX跨站请求
- 弹出窗口中不执行javascript方法,求救!
- 请教各位大侠,能否把下面这个脚本用javascript改写,多谢各位,我在线等待!!
- js能不能把HTC当作一个对象,然后new一个调用HTC相应的函数方法?
- 关于isFinite函数参数格式的疑问。
- 请教大师们,js拼接字符串的问题
//var SYSWINDEFAULTHEIGHT = 150;
好像没有窗口默认的高和宽啦