javascript创建层问题
网上找了段代码,本人对javascript初学,有两问题望高手解答,感谢!
1、屏蔽<确定>按钮,弹出层后,屏幕右边会往中间缩,关闭屏幕显示再还原,不屏幕确定按钮又正常?
2、弹出窗口,里面页面是链接一个asp文件,我想要在asp里面关闭这个层,该怎做?
代码如下 :
var IMGFOLDERPATH = '../inc/images/';//图片路径配置
//var IMGFOLDERPATH = 'images/';//图片路径配置
var CONTEXTPATH = '';//弹出框内页面路径配置
var isIE = navigator.userAgent.toLowerCase().indexOf("msie") != -1;
var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie 6.0") != -1;
var isGecko = navigator.userAgent.toLowerCase().indexOf("gecko") != -1;
var isQuirks = document.compatMode == "BackCompat";
function $(ele) {
if (typeof(ele) == 'string'){
ele = document.getElementById(ele)
if(!ele){
return null;
}
}
if(ele){
Core.attachMethod(ele);
}
return ele;
}
function $T(tagName,ele){
ele = $(ele);
ele = ele || document;
var ts = ele.getElementsByTagName(tagName);//此处返回的不是数组
var arr = [];
var len = ts.length;
for(var i=0;i<len;i++){
arr.push($(ts[i]));
}
return arr;
}
function stopEvent(event){//阻止一切事件执行,包括浏览器默认的事件
event = window.event||event;
if(!event){
return;
}
if(isGecko){
event.preventDefault();
event.stopPropagation();
}
event.cancelBubble = true
event.returnValue = false;
}
Array.prototype.remove = function(s){
for(var i=0;i<this.length;i++){
if(s == this[i]){
this.splice(i, 1);
}
}
}
if(window.HTMLElement){//给FF添加IE专有的属性和方法
HTMLElement.prototype.__defineGetter__("parentElement",function(){
if(this.parentNode==this.ownerDocument)return null;
return this.parentNode;
});
HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
var r=this.ownerDocument.createRange();
r.setStartBefore(this);
var df=r.createContextualFragment(sHTML);
this.parentNode.replaceChild(df,this);
return sHTML;
});
HTMLElement.prototype.__defineGetter__("outerHTML",function(){
var attr;
var attrs=this.attributes;
var str="<"+this.tagName;
for(var i=0;i<attrs.length;i++){
attr=attrs[i];
if(attr.specified)
str+=" "+attr.name+'="'+attr.value+'"';
}
if(!this.canHaveChildren)
return str+">";
return str+">"+this.innerHTML+"</"+this.tagName+">";
});
HTMLElement.prototype.__defineSetter__("innerText",function(sText){
var parsedText=document.createTextNode(sText);
this.innerHTML=parsedText;
return parsedText;
});
HTMLElement.prototype.__defineGetter__("innerText",function(){
var r=this.ownerDocument.createRange();
r.selectNodeContents(this);
return r.toString();
});
}
var $E = {};
$E.$A = function(attr,ele) {
ele = ele || this;
ele = $(ele);
return ele.getAttribute?ele.getAttribute(attr):null;
}
$E.getTopLevelWindow = function(){
var pw = window;
while(pw!=pw.parent){
pw = pw.parent;
}
return pw;
}
$E.hide = function(ele) {
ele = ele || this;
ele = $(ele);
ele.style.display = 'none';
}
$E.show = function(ele) {
ele = ele || this;
ele = $(ele);
ele.style.display = '';
}
$E.visible = function(ele) {
ele = ele || this;
ele = $(ele);
if(ele.style.display=="none"){
return false;
}
return true;
}
var Core = {};
Core.attachMethod = function(ele){
if(!ele||ele["$A"]){
return;
}
if(ele.nodeType==9){
return;
}
var win;
try{
if(isGecko){
win = ele.ownerDocument.defaultView;
}else{
win = ele.ownerDocument.parentWindow;
}
for(var prop in $E){
ele[prop] = win.$E[prop];
}
}catch(ex){
//alert("Core.attachMethod:"+ele)//有些对象不能附加属性,如flash
}
}
function Dialog(strID){
if(!strID){
alert("错误的Dialog ID!");
return;
}
this.ID = strID;
this.isModal = true;
this.Width = 400;
this.Height = 300;
this.Top = 0;
this.Left = 0;
this.ParentWindow = null;
this.onLoad = null;
this.Window = null;
this.Title = "";
this.URL = null;
this.innerHTML=null
this.innerElementId=null
this.DialogArguments = {};
this.WindowFlag = false;
this.Message = null;
this.MessageTitle = null;
this.ShowMessageRow = false;
this.ShowButtonRow = true;
this.Icon = null;
this.bgdivID=null;
}
Dialog._Array = [];
Dialog.prototype.showWindow = function(){
if(isIE){
this.ParentWindow.showModalessDialog( this.URL, this.DialogArguments, "dialogWidth:" + this.Width + ";dialogHeight:" + this.Height + ";help:no;scroll:no;status:no") ;
}
if(isGecko){
var sOption = "location=no,menubar=no,status=no;toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=no";
this.Window = this.ParentWindow.open( '', this.URL, sOption, true ) ;
var w = this.Window;
if ( !w ){
alert( "发现弹出窗口被阻止,请更改浏览器设置,以便正常使用本功能!" ) ;
return ;
}
w.moveTo( this.Left, this.Top ) ;
w.resizeTo( this.Width, this.Height+30 ) ;
w.focus() ;
w.location.href = this.URL ;
w.Parent = this.ParentWindow;
w.dialogArguments = this.DialogArguments;
}
}