??xml version="1.0" encoding="utf-8" standalone="yes"?>
比如我想要设定日志保存在webapp/log
参考了|上资料Q?span class="Apple-converted-space">
http://hi.baidu.com/suofang/blog/item/6cf2befbd1ff07234f4aea90.html
下面是引入内容:(x)
Ҏ(gu)一主要是扩展了log4j的RollingFileAppenderc,其他的FileAppender同样道理。扩展的Ҏ(gu)Q就是用一个子cd覆盖setFileҎ(gu)Q这个方法在log4jd配置文g生成appender的时候调用,传入的就是配|文件中的\径,q样我就可以按照自己的想法在路径前面加上根\径了。这U方法可以在log4j.properties中用相对路径自由配置log4j.appender.A1.File属性来军_生成的日志相对web应用根目录的位置?span class="Apple-converted-space">
Ҏ(gu)二是利用服务器vm中已l存在的环境变量?{catalina.home}来设|相对于${catalina.home}的日志\径,日志只能攑ֈ服务器子目录里,而且如果是用的其它服务器Q则要改对应的环境变量。此Ҏ(gu)q_UL不方ѝ?span class="Apple-converted-space">
Ҏ(gu)三是扩展ActionServletc,覆盖其init()Ҏ(gu)Q新Ҏ(gu)中蝲?span class="hilite1" style="background-color: rgb(255,255,0)">log4j.properties位置的参敎ͼ可以自由配置log4j的配|文件的名字和存放位|。也可自由配|?span class="hilite1" style="background-color: rgb(255,255,0)">log4j日志文g的相对于当前应用的\径?span class="Apple-converted-space">
对于W三个方法,作者提Z个问题:(x)
log4j配置文g的位|,不让其在web-inf/classes目录Q因为在加蝲此Servlet之前Q服务器如tomcat启动时会(x)自动搜烦web-inf目录?span class="hilite2" style="background-color: rgb(85,255,85)">web-inf/classes目录?span class="hilite1" style="background-color: rgb(255,255,0)">log4j.properties文gQ如有则自动加蝲?span class="hilite1" style="background-color: rgb(255,255,0)">log4j属性文件加载后,׃该属性文件中log4j.appender.A1.File的值用的是相对路径Q自动加载配|便?x)出错?x)
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: WEB-INF\logs\bysxxglxt.log
(pȝ找不到指定的路径?
管后面加蝲扩展的ActionServlet中正设|了log4j属性文件ƈ正常加蝲了,但还是报的这个错Q怪不爽的。只有更?span class="hilite1" style="background-color: rgb(255,255,0)">log4j属性文件名字或者更改其存放位置Q让其不能自动加载了Q不q还是有两个警告Q?span class="Apple-converted-space">
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
新的发现Q?span class="Apple-converted-space">
׃spring也会(x)加蝲log4j.propertiesQ如果加载不到就往控制台打log信息Q总觉得有些碍|于是惛_法去掉。Spring提供了一个Log4jConfigListenerQ本w就能通过web.xml中配|来指定位置加蝲log4j配置文g和log输出路径Q注意该listener需要放在spring的Listener之前?span class="Apple-converted-space">
事实上,Log4jConfigListener更适合log4j在web工程中用,原因如下Q?span class="Apple-converted-space">
1. 动态的改变记录U别和策略,不需要重启Web应用Q如《Effective Enterprise Java》所说?span class="Apple-converted-space">
2. 把log文g定在 /WEB-INF/logs/ 而不需要写l对路径?span class="Apple-converted-space">
因ؓ(f) pȝ把web目录的\径压入一个叫webapp.root的系l变量。这样写log文g路径时不用写l对路径?
log4j.appender.logfile.File=${webapp.root}/WEB-INF/logs/myfuse.log
3. 可以?span class="hilite1" style="background-color: rgb(255,255,0)">log4j.properties和其他properties一h?WEB-INF/ Q而不是Class-Path?span class="Apple-converted-space">
4.log4jRefreshInterval?0000表示 开一条watchdogU程?0U扫描一下配|文件的变化;
在web.xml d
opacity
是CSS 3里的一个属性,用来讑֮元素的透明度。当然现在还只有部分浏览器支持?/p>
不过各个览器都有自qU有属性来支持,其中包括老版本的Mozilla和SafariQ?/p>
filter:alpha(opacity)
-moz-opacity
-khtml-opacity
很不q的是,你没看见OperaQ老版本的Operaq没有什么私有属性可以代?code style="padding-right: 2px; padding-left: 2px; font-size: 12px; padding-bottom: 1px; color: rgb(102,51,0); padding-top: 1px">opacity。(新版Opera已经支持opacity
Q?/p>
所以以前用CSS讑֮一个元素半透明的话Q可能会(x)q样?
用javascript来设定一个元素ؓ(f)半透明:
var ImgAlt = new Array();//鼠标放上LC的文字
ImgAlt[0] = "国《国家地理杂志?"
ImgAlt[1] = "国《国家地理杂志?"
ImgAlt[2] = "国《国家地理杂志?"
ImgAlt[3] = "国《国家地理杂志?"
ImgAlt[4] = "国《国家地理杂志?"
ImgAlt[5] = "国《国家地理杂志?"
ImgAlt[6] = "国《国家地理杂志?"
ImgAlt[7] = "国《国家地理杂志?"
var ImgHerf = new Array();//链接
ImgHerf[0] = "ImgHerf[1] = "ImgHerf[2] = "http://www.12free.cn/kelven/mypic/Usa_geography/pic2006/page_03.htm"
ImgHerf[3] = "ImgHerf[4] = "ImgHerf[5] = "ImgHerf[6] = "ImgHerf[7] = "http://www.12free.cn/kelven/mypic/Usa_geography/pic2006/page_08.htm"
var step=0;
function slideit(){
var oImg = document.getElementById("javascript.img");
if (document.all){oImg.filters.blendTrans.apply();}
oImg.src=ImgSrc[step];
document.getElementById("javascript.a").href=ImgHerf[step];
oImg.title=ImgAlt[step];
if (document.all){oImg.filters.blendTrans.play();}
step = (step<(ImgSrc.length-1))?(step+1):0;
(new Image()).src = ImgSrc[step];//加蝲下一个图?br />}
setInterval("slideit()",3000);
//-->
</script>
</body>
</html>
.xWin {
position:absolute;
cursor:default;
border-width:2px;
border-style:outset;
padding:0px;
font-size:12px;
overflow:hidden;
display:block;
}
.xWin .xWinSetting {
display:none;
}
.xWin .xTitle {
color:#FFFFFF;
height:20px;
display:block;
}
.xWin .xTitle input {
background-color:transparent;
color:#FFFFFF;
border-width:0px;
border-style:solid;
height:20px;
width:16px;
line-height:20px;
font-family:webdings;
font-size:10px;
margin:0px;
padding:0px;
text-align:center;
float:right;
display:block;
}
.xWin .xTitle .xWinTitleCloseButton {
}
.xWin .xTitle .xWinTitleMaxButton {
}
.xWin .xTitle .xWinTitleMinButton {
}
.xWin .xTitle .xWinTitleContent {
color:#FFFFFF;
font-size:12px;
height:18px;
line-height:20px;
margin:0px;
padding-left:3px;
float:left;
display:block;
overflow:hidden;
white-space:nowrap;
text-align:left;
cursor:default;
}
.xWin .xWinBody {
margin:0px;
background-color:#FFFFFF;
color:#000000;
padding:3px;
font-size:12px;
overflow:auto;
position:relative;
display:block;
}
.xShadow {
position:absolute;
display:block;
background-Color:#000000;
color:#FFFFFF;
}
</style>
<script type="text/javascript">
//<![CDATA[
//********************/
// x pd?xWin
// 作者:(x)Hutia
// 未经同意不得转蝲或用于商业用?br />//********************/
/*
说明Q?br /> xpd是Hutia开发的pdJS代码Q配合相应的css后可以实现快速的自定义标{?br /> 目前xpd支持的浏览器cd为:(x)IE5.5, FF1.5
xWin的标{ؓ(f) <div class="xwin">content</div>
支持属性:(x)
int left, int top, int width, int height
支持Ҏ(gu)Q?br /> Close(), Destroy(), Max([bolean Variable]), Min([bolean Variable]),
MoveTo(int x, int y), ResizeTo(int x, int y), SetContent(string Variable | htmlObject Variable)
SetTitle(string Variable), ShowHide()
*/
//**载入CSS*****
var xWinCssFilePath="sp\/css\/xwin.css";
//document.write("<style>@import url("+xWinCssFilePath+");</style>");
//**浏览器U类*****
var BROWSERNAME="";
switch(navigator.appName.toLowerCase()){
case "netscape":
BROWSERNAME="ns";
break;
case "microsoft internet explorer":
default:
BROWSERNAME="ie";
break;
}
//**讄初始化变?*****
switch(BROWSERNAME){
case "ns":
window.addEventListener("load",_xWin_init,false);
break;
case "ie":
default:
window.attachEvent("onload",_xWin_init);
}
//**讄全局定时?*****
if(typeof(__xSeriaTimer__)=="undefined"){
var __xSeriaTimer__={
events:new Array(),
objs:new Array(),
handle:null,
exec:function(){
for(var i=0;i<__xSeriaTimer__.events.length;i++){
try{
with(__xSeriaTimer__.objs[i]){
eval(__xSeriaTimer__.events[i]);
}
}catch(e){}
}
},
pop:function(i){
__xSeriaTimer__.events[i]=null;
__xSeriaTimer__.objs[i]=null;
},
push:function(strV,obj){
for(var i=0;i<__xSeriaTimer__.events.length;i++){
if(__xSeriaTimer__.events[i]==null){
__xSeriaTimer__.events[i]=strV;
__xSeriaTimer__.objs[i]=obj;
return(i);
}
}
__xSeriaTimer__.events[i]=strV;
__xSeriaTimer__.objs[i]=obj;
return(i);
},
start:function(){
__xSeriaTimer__.stop();
__xSeriaTimer__.handle=setInterval(__xSeriaTimer__.exec,30);
},
stop:function(){
clearInterval(__xSeriaTimer__.handle);
}
};
__xSeriaTimer__.start();
}
//**初始化函?*****
function _xWin_init(){
var allTheWindows=document.getElementsByTagName("div");
for(var i=0;i<allTheWindows.length;i++){
if(allTheWindows[i].className=="xWin")_xWin_event_doInit(allTheWindows[i]);
}
}
//**事g响应函数?*****
function _xWin_event_doInit(element){
//初始化变?br /> element.ownerDocument.index=isNaN(element.ownerDocument.index)?10000:parseInt(element.ownerDocument.index)+1;
element.x0=0;element.y0=0;
element.x1=0;element.y1=0;
element.w0=0;element.h0=0;
element.offx=6;element.offy=6;
element.padx=0;element.pady=0;
element.minW=90;element.minH=(BROWSERNAME=="ns"?20:20);
element.moveable=false;
element.resizable=false;
element.hover='orange';element.normal='#336699';
element.minButton=BROWSERNAME=="ie"?"0":"_";
element.maxButton=BROWSERNAME=="ie"?"1":"=";
element.normalButton=BROWSERNAME=="ie"?"2":"+";
element.closeButton=BROWSERNAME=="ie"?"r":"X";
element._title="Untitled Window";
element._body="";
element._winRect={l:0,t:0,w:0,h:0};
element._restoredWinRect={l:0,t:0,w:0,h:0};
element._windowState="normal";
element.settingNode=getElementByClassName(element,"xWinSetting");
if(!element.settingNode){
element.settingNode=document.createElement("div");
element.settingNode.className="xWinSetting";
element.settingNode.xwin=element;
element.appendChild(element.settingNode);
}
element.xwin=element;
//讄Ҏ(gu)
element.Close=_xWin_method_Close;
element.Destroy=_xWin_method_Destroy;
element.GetSetting=_xWin_method_GetSetting;
element.Max=_xWin_method_Max;
element.Min=_xWin_method_Min;
element.MoveTo=_xWin_method_MoveTo;
element.ResizeTo=_xWin_method_ResizeTo;
element.SetContent=_xWin_method_SetContent;
element.SetTitle=_xWin_method_SetTitle;
element.ShowHide=_xWin_method_ShowHide;
//讄事g
element.onmousedown=_xWin_event_doMDown;
element.onmouseup=element.onlosecapture=_xWin_event_doMUp;
element.onmousemove=_xWin_event_doMMove;
element.onclick=_xWin_event_doClick;
element.onselectstart=element.onselect=_xWin_event_doSelect;
//记录昄风格
var tempDisplay=element.style.display;
//改变昄风格
element.style.display="block";
//讄H口变量
var w=parseInt(element.GetSetting("width"));
w=isNaN(w)?(element.offsetWidth+10):parseInt(w);
w=w<element.minW?element.minW:w;
var h=parseInt(element.GetSetting("height"));
h=isNaN(h)?(element.offsetHeight+30):parseInt(h);
h=h<element.minH?element.minH:h;
var l=parseInt(element.GetSetting("left"));
l=isNaN(l)?element.offsetLeft:parseInt(l);
l=l<1?1:l;
var t=parseInt(element.GetSetting("top"));
t=isNaN(t)?element.offsetTop:parseInt(t);
t=t<1?1:t;
var z=element.ownerDocument.index;
var title=new String(element.GetSetting("title"));
//讄H口标题
element.oTitle=element.ownerDocument.createElement("div");
element.oTitle.xwin=element;
element.oTitle.className="xTitle";
element.appendChild(element.oTitle);
//讄H口标题内容
element.oTitleContent=element.ownerDocument.createElement("span");
element.oTitleContent.xwin=element;
element.oTitleContent.className="xWinTitleContent";
element.oTitle.appendChild(element.oTitleContent);
element.oTitleContent.ondblclick=function(){this.xwin.Max();};
element.SetTitle(title);
//讄H口标题关闭按钮
element.oTitleCButton=element.ownerDocument.createElement("input");
element.oTitleCButton.xwin=element;
element.oTitleCButton.type="button";
element.oTitleCButton.className="xWinTitleCloseButton";
element.oTitle.appendChild(element.oTitleCButton);
element.oTitleCButton.onclick=function(){this.xwin.ShowHide("none");};
element.oTitleCButton.value=element.closeButton;
//讄H口标题最大化按钮
element.oTitleMaButton=element.ownerDocument.createElement("input");
element.oTitleMaButton.xwin=element;
element.oTitleMaButton.type="button";
element.oTitleMaButton.className="xWinTitleMaxButton";
element.oTitle.appendChild(element.oTitleMaButton);
element.oTitleMaButton.onclick=function(){this.xwin.Max();};
element.oTitleMaButton.value=element.maxButton;
//讄H口标题最化按钮
element.oTitleMButton=element.ownerDocument.createElement("input");
element.oTitleMButton.xwin=element;
element.oTitleMButton.type="button";
element.oTitleMButton.className="xWinTitleMinButton";
element.oTitle.appendChild(element.oTitleMButton);
element.oTitleMButton.onclick=function(){this.xwin.Min();};
element.oTitleMButton.value=element.minButton;
//讄H口内容
element.oContent=element.ownerDocument.createElement("div");
element.oContent.xwin=element;
element.oContent.className="xWinBody";
element.appendChild(element.oContent);
oC=element.firstChild;
while(oC){
tC=oC.nextSibling;
if(oC!=element.oTitle&&oC!=element.oContent){
element.oContent.appendChild(oC);
}
oC=tC;
}
//讄H口阴媄
element.oShadow=element.ownerDocument.createElement("div");
element.oShadow.xwin=element;
element.oShadow.className="xShadow";
element.parentNode.insertBefore(element.oShadow,element.nextSibling);
element.oShadow.style.zIndex=z-1;
element.MoveTo(l,t);
element.ResizeTo(w,h);
//恢复昄风格
element.style.display=tempDisplay;
//讄H口样式
with(element.style){
zIndex=z;
backgroundColor=element.normal;
color=element.normal;
}
padx=element.offsetWidth-element.clientWidth;
pady=element.offsetHeight-element.clientHeight;
}
function _xWin_event_doMDown(evt){
var e=evt?evt:window.event;
var eSrc=e.srcElement?e.srcElement:e.target;
var leftButton=e.srcElement?e.button==1:e.button==0;
if(this.style.zIndex!=this.ownerDocument.index){//窗口放到最?br /> this.ownerDocument.index+=2;
var idx = this.ownerDocument.index;
this.style.zIndex=idx;
this.nextSibling.style.zIndex=idx-1;
}
if(eSrc==this.oTitleContent&&leftButton&&this._windowState=="normal"){//如果开始拖?br /> //锁定标题?
document.captureEvents?document.captureEvents("mousemove",this.oTitle):this.oTitle.setCapture();
//定义对象;
var win = this;
var sha = win.nextSibling;
//记录鼠标和层位置;
this.x0 = e.clientX;
this.y0 = e.clientY;
this.x1 = parseInt(win.style.left);
this.y1 = parseInt(win.style.top);
//改变风格;
this.oTitle.style.backgroundColor = this.hover;
win.style.borderColor = this.hover;
this.oTitle.nextSibling.style.color = this.hover;
sha.style.left = this.x1 + this.offx;
sha.style.top = this.y1 + this.offy;
this.moveable = true;
return(true);
}
if(this.style.cursor!="default"&&this._windowState=="normal"){//开始改变大?br /> //锁定标题?
document.captureEvents?document.captureEvents("mousemove",this.oTitle):this.oTitle.setCapture();
//定义对象;
var win = this;
var sha = win.nextSibling;
//记录鼠标位置和层位置和大?
this.x0=e.clientX;
this.y0=e.clientY;
this.x1=parseInt(win.offsetLeft);
this.y1=parseInt(win.offsetTop);
this.w0=parseInt(win.offsetWidth);
this.h0=parseInt(win.offsetHeight);
//改变风格;
this.oTitle.style.backgroundColor = this.hover;
win.style.borderColor = this.hover;
this.oTitle.nextSibling.style.color = this.hover;
sha.style.left = this.x1 + this.offx;
sha.style.top = this.y1 + this.offy;
this.resizable = true;
return(true);
}
}
function _xWin_event_doMUp(evt){
var e=evt?evt:window.event;
document.releaseEvents?document.releaseEvents("mousemove",this.oTitle):this.oTitle.releaseCapture();
if(this.moveable){
var win = this;
var sha = win.nextSibling;
var msg = this.oTitle.nextSibling;
win.style.borderColor = "";
this.oTitle.style.backgroundColor = "";
msg.style.color = "";
sha.style.left = this.oTitle.parentNode.style.left;
sha.style.top = this.oTitle.parentNode.style.top;
this.moveable = false;
return(false);
}
if(this.resizable){
var win = this;
var sha = win.nextSibling;
var msg = this.oTitle.nextSibling;
win.style.borderColor = "";
this.oTitle.style.backgroundColor = "";
msg.style.color = "";
sha.style.left = this.oTitle.parentNode.style.left;
sha.style.top = this.oTitle.parentNode.style.top;
sha.style.width = this.oTitle.parentNode.style.width;
sha.style.height = this.oTitle.parentNode.style.height;
this.style.cursor="default";
this.resizable = false;
return(false);
}
}
function _xWin_event_doMMove(evt){
var e=evt?evt:window.event;
if(this.moveable){//拖动H口
this.MoveTo(this.x1 + e.clientX - this.x0, this.y1 + e.clientY - this.y0);
return(true);
}
if(this.resizable){//改变H口大小
var xxx=this.style.cursor.substring(0,2).match(/[we]/i);
var yyy=this.style.cursor.substring(0,2).match(/[ns]/i);
l=this.offsetLeft;
t=this.offsetTop;
w=parseInt(this.style.width);
h=parseInt(this.style.height);
if(xxx=="w"){
l=this.x1+e.clientX - this.x0;
w=this.w0+this.x0-e.clientX;
if(l<0){w+=l;l=0;}
if(w<this.minW){l=l+w-this.minW;w=this.minW;}
}
if(xxx=="e"){
w=this.w0+e.clientX-this.x0;
w=w<this.minW?this.minW:w;
}
if(yyy=="n"){
t=this.y1+e.clientY - this.y0;
h=this.h0+this.y0-e.clientY;
if(t<0){h+=t;t=0;}
if(h<this.minH){t=t+h-this.minH;h=this.minH;}
}
if(yyy=="s"){
h=this.h0+e.clientY-this.y0;
h=h<this.minH?this.minH:h;
}
this.MoveTo(l,t);
this.ResizeTo(w,h);
return(true);
}
if(this._windowState=="normal"){
var cc="";
x=window.getRealLeft(this);
y=window.getRealTop(this);
w=parseInt(this.offsetWidth);
h=parseInt(this.offsetHeight);
if(e.clientY-y<5)cc+="n";
if(y+h-e.clientY<5)cc+="s";
if(e.clientX-x<5)cc+="w";
if(x+w-e.clientX<5)cc+="e";
if(cc!=""){
this.style.cursor=cc+"-resize";
return(true);
}
if(this.style.cursor!="default"){
this.style.cursor="default";
}
}
}
function _xWin_event_doClick(evt){
var e=evt?evt:window.event;
var eSrc=e.srcElement?e.srcElement:e.target;
switch(eSrc){
}
}
function _xWin_event_doSelect(evt){
var e=evt?evt:window.event;
var eSrc=e.srcElement?e.srcElement:e.target;
if(eSrc==this.oTitle||this.oTitle.contains(eSrc)){
e.cancelBubble=true;
e.returnValue=false;
return(false);
}
}
function _xWinParentNode_event_doScroll(evt){
if(!this.minimizedWindows)return(true);
for(var i=0;i<this.minimizedWindows.length;i++){
this.minimizedWindows[i].Min(true);
}
}
//**Ҏ(gu)函数?*****
function _xWin_method_Close(){
this.Destroy();
}
function _xWin_method_Destroy(){
if(this.minIndex){
this.parentNode.minimizedWindows[this.minIndex]=null;
this.minIndex=null;
}
this.outerHTML="";
}
function _xWin_method_GetSetting(attributeName){
var settingString=this.settingNode.innerHTML;
if(!attributeName)return(settingString);
var regE=new RegExp(attributeName+"=[ \t]*\"?([^\"]*)","i");
var re=settingString.match(regE);
if(re){
return(re[1]);
}else{
return(re);
}
}
function _xWin_method_Max(reV){
if(this._windowState=="maximize"&&(!reV)){
//q原父节点overflow属?br /> this.parentNode.style.overflow=this.parentNode.restoredStyle_overflow;
this.MoveTo(this._restoredWinRect.l,this._restoredWinRect.t);
this.ResizeTo(this._restoredWinRect.w,this._restoredWinRect.h);
this.oTitleMButton.value = this.minButton;
this.oTitleMaButton.value = this.maxButton;
this._windowState="normal";
}else{
if(this._windowState=="normal"){
this._restoredWinRect.l=this._winRect.l;this._restoredWinRect.t=this._winRect.t;
this._restoredWinRect.w=this._winRect.w;this._restoredWinRect.h=this._winRect.h;
}
if(this.minIndex!=null){
this.parentNode.minimizedWindows[this.minIndex]=null;
this.minIndex=null;
}
if(this.minTimeHandle!=null){
__xSeriaTimer__.pop(this.minTimeHandle);
this.minTimeHandle=null;
}
//U录父节点overflow属?br /> this.parentNode.restoredStyle_overflow=this.parentNode.style.overflow;
//改变父节点overflow属?br /> this.parentNode.style.overflow="hidden";
this.MoveTo(0,0);
if(this.parentNode!=document.body){
w=this.parentNode.clientWidth-5;
h=this.parentNode.clientHeight-4;
}else{
w=document.documentElement.clientWidth-5;
h=document.documentElement.clientHeight-4;
}
this.ResizeTo(w,h);
this.oTitleMButton.value = this.minButton;
this.oTitleMaButton.value = this.normalButton;
this._windowState="maximize";
this.scrollIntoView();
}
}
function _xWin_method_Min(reV){
if(this._windowState=="minimize"&&(!reV)){
this.MoveTo(this._restoredWinRect.l,this._restoredWinRect.t);
this.ResizeTo(this._restoredWinRect.w,this._restoredWinRect.h);
this.oTitleMButton.value = this.minButton;
this.oTitleMaButton.value = this.maxButton;
this._windowState="normal";
this.parentNode.minimizedWindows[this.minIndex]=null;
this.minIndex=null;
if(this.minTimeHandle!=null){
__xSeriaTimer__.pop(this.minTimeHandle);
this.minTimeHandle=null;
}
}else{
if(this._windowState=="normal"){
this._restoredWinRect.l=this._winRect.l;this._restoredWinRect.t=this._winRect.t;
this._restoredWinRect.w=this._winRect.w;this._restoredWinRect.h=this._winRect.h;
}else{
//q原父节点overflow属?br /> try{
this.parentNode.style.overflow=this.parentNode.restoredStyle_overflow;
}catch(e){}
}
if(!this.parentNode.minimizedWindows)this.parentNode.minimizedWindows=new Array();
if(this._windowState!="minimize"){
for(var i=0;i<this.parentNode.minimizedWindows.length;i++){
if(this.parentNode.minimizedWindows[i]==null)break;
}
this.parentNode.minimizedWindows[i]=this;
}else{
i=this.minIndex;
}
this.ResizeTo(0,0);
var w=this.offsetWidth;
var h=this.offsetHeight;
var mw=getParentRect(this).mw;
var mh=getParentRect(this).mh;
var n=parseInt(mw/w);
var t=parseInt(i/n)+1;
this.MoveTo(w*(i%n),mh-t*h-1);
if(mh>getParentRect(this).mh){
this.MoveTo(w*(i%n),mh-t*h-200);
mh=getParentRect(this).mh;
this.MoveTo(w*(i%n),mh-t*h-1);
}
this.minIndex=i;
this.oTitleMButton.value = this.normalButton;
this.oTitleMaButton.value = this.maxButton;
this._windowState="minimize";
if(this.minTimeHandle==null){
this.minTimeHandle=__xSeriaTimer__.push("Min(true)",this);
this.scrollIntoView();
}
}
}
function _xWin_method_MoveTo(x,y){
var win = this.oTitle.parentNode;
var sha = win.nextSibling;
x=isNaN(x)?0:parseInt(x);
y=isNaN(y)?0:parseInt(y);
x=x<0?0:x;
y=y<0?0:y;
this.style.left=x+"px";
this.style.top=y+"px";
sha.style.left = parseInt(win.style.left) + ((this.moveable||this.resizable)?this.offx:0)+"px";
sha.style.top = parseInt(win.style.top) + ((this.moveable||this.resizable)?this.offy:0)+"px";
this._winRect.l=x;
this._winRect.t=y;
}
function _xWin_method_ResizeTo(w,h){
var win = this;
var sha = win.nextSibling;
var w=isNaN(w)?this.minW:parseInt(w);
var h=isNaN(h)?this.minH:parseInt(h);
var w=w<this.minW?this.minW:w;
var h=h<this.minH?this.minH:h;
this.style.width=w+"px";
this.style.height=h+"px";
this.oTitle.style.width=parseInt(this.clientWidth)+"px";
var wTC=this.clientWidth;
for(var i=0;i<this.oTitle.childNodes.length;i++){
if(this.oTitle.childNodes[i]!=this.oTitleContent){wTC-=this.oTitle.childNodes[i].offsetWidth;}
}
wTC-=8;
this.oTitleContent.style.width=(wTC<1?1:wTC)+"px";
var wC=this.clientHeight-this.oTitle.offsetHeight-6;
this.oContent.style.height=(wC<1?1:wC)+"px";
this.oContent.style.width=parseInt(this.clientWidth-6)+"px";
sha.style.left = parseInt(win.style.left) + ((this.moveable||this.resizable)?this.offx:0)+"px";
sha.style.top = parseInt(win.style.top) + ((this.moveable||this.resizable)?this.offy:0)+"px";
sha.style.width = parseInt(win.style.width)+"px";
sha.style.height = parseInt(win.style.height)+"px";
this._winRect.w=w;
this._winRect.h=h;
}
function _xWin_method_SetContent(v){
if(this.oContent){
if(v==null||v==undefined||v==""){this._body=this.oContent.innerHTML="";return(this.oContent);}
if(typeof(v)=="string"){
this._body=this.oContent.innerHTML=v;
return(this.oContent);
}else{
try{
this.oContent.innerHTML="";
this._body=this.oContent.appendChild(v);
return(this.oContent);
}catch(e){
throw(e);
}
}
}else{
this._body=v;
return(null);
}
}
function _xWin_method_SetTitle(strT){
this._title=strT==null?this._title:strT;
if(this.oTitleContent){
setInnerText(this.oTitleContent,this._title);
}
}
function _xWin_method_ShowHide(dis){
var bdisplay = (dis==null)?((this.style.display=="none")?"":"none"):dis;
this.style.display = bdisplay;
this.nextSibling.style.display = bdisplay;
if(bdisplay=="none"){
if(this._windowState=="minimize"){
this.parentNode.minimizedWindows[this.minIndex]=null;
this.minIndex=null;
}
}else{
if(this._windowState=="minimize"){
this.Min();
}
}
}
//**通用函数?**
function getRealLeft(o){
var l=o.offsetLeft-o.scrollLeft;
while(o=o.offsetParent){
l+=o.offsetLeft-o.scrollLeft;
}
return(l);
}
function getRealTop(o){
var t=o.offsetTop-o.scrollTop;
while(o=o.offsetParent){
t+=o.offsetTop-o.scrollTop;
}
return(t);
}
function setInnerText(obj,text){
switch(BROWSERNAME){
case "ns":
obj.textContent=text;
break;
case "ie":
default:
obj.innerText=text;
}
}
function getElementByClassName(obj,className){
for(var i=0;i<obj.childNodes.length;i++){
if(obj.childNodes[i].className==className)return(obj.childNodes[i]);
}
return(null);
}
function getParentRect(obj){
var re=new Object();
if(obj.parentNode!=document.body){
re.mw=Math.max(obj.parentNode.scrollWidth,obj.parentNode.clientWidth);
re.mh=Math.max(obj.parentNode.scrollHeight,obj.parentNode.clientHeight);
}else{
re.mw=Math.max(document.documentElement.scrollWidth,document.documentElement.clientWidth);
re.mh=Math.max(document.documentElement.scrollHeight,document.documentElement.clientHeight);
}
return(re);
}
//]]>
</script>
</head>
<body>
<div class="xWin" id="win1" >
<span class="xWinSetting">width="400" height="400" top="300" left="100" title="我就是传说中那个长的窗口标?</span>
我就是传说中那个长的窗口标题我是传说
<div class="xWin" id="win30" >
<span class="xWinSetting"> width="100" top="20" left="20" title="我就是传说中那个长的窗口标?</span>
中那个超长的H口标题我就是传说中那个?lt;br/>长的H口标题我就是传说中那个长
</div>
的窗口标题我是传说中那个超长的H口标题我就是传说中那个长的窗口标题我是传说中那个超长的H口标题
我就是传说中那个长?br /> <div class="xWin" id="win31" >
<span class="xWinSetting">width="100" top="40" left="40" title="我就是传说中那个长的窗口标? </span>
中那个超长的H口标题我就是传说中那个?lt;br/>长的H口标题我就是传说中那个长
</div>
H口标题我就是传说中?br /> 个超长的H口标题我就是传说中那个长的窗口标题我是传说中那个超长的H口标题我就是传说中?br /> 个超长的H口标题我就是传说中那个长的窗口标?br /> c<br/>
12345
</div>
<div class="xWin" id="win2">
<span class="xWinSetting"> width="200" top="270" left="140" title="我就是传说中那个长的窗口标?</span>
我是H口2<br/>
我是H口2<br/>
我是H口2<br/>
我是H口2<br/>
<a href="javascript:void(0);">更换标题</a>
我是H口2<br/>
我是H口2<br/>
我是H口2<br/>
我是H口2<br/>
</div>
<a href="javascript:win1.ShowHide('');void(0);">win1</a>
<a href="javascript:win2.ShowHide('');void(0);">win2</a>
<a href="javascript:document.getElementById('win3').ShowHide('');void(0);">win3</a>
<a href="javascript:document.getElementById('win4').ShowHide('');void(0);">win4</a>
<div id="ssss"></div>
</body>
</html>
效果Q?br />
二、怎样才让在showModalDialog和showModelessDialog的超q接不弹出新H口Q?/strong>
三、怎样才刷新showModalDialog和showModelessDialog里的内容Q?/strong>
<body onkeydown="if (event.keyCode==116){reload.click()}"> filename.htm替换成网늚名字然后它攑ֈ你打开的网里Q按F5可以刷CQ注意,q个要配?lt;base target="_self">使用Q不然你按下F5?x)弹出新H口的?/p>
四、如何用javascriptxshowModalDialog(或showModelessDialog)打开的窗口?/strong>
五、showModalDialog和showModelessDialog数据传递技巧?/strong>
一般的传递方式:(x) 同时我也可以操作var_id变量 同样q可以对ȝ口的M对象q行操作Q如form对象里的元素?br /> window.dialogArguments.form1.index1.value="q是在设|index1元素的?
六、多个showModelessDialog的相互操作?/strong>
以下代码的主要作用是在一个showModelessDialog里移动别一个showModelessDialog的位|?/p>
L件的部䆾js代码?br /> var s1=showModelessDialog('控制.htm',window,"dialogTop:1px;dialogLeft:1px"Q?/打开控制H口 控制.htm的部份代码?br /> <script> 以上关键部䆾是:(x) q个例子只是现实showModelessDialog与showModelessDialog之间的位|操作功能,通过q个原理Q在showModelessDialog之间怺控制各自的显C页面,传递变量和数据{。这要看各位的发挥了?/p>
在被打开的网里加上<base target="_self">可以了。这句话一般是攑֜<html>?lt;body>之间的?/p>
在showModalDialog和showModelessDialog里是不能按F5h的,又不能弹单。这个只能依靠javascript了,以下是相关代码:(x)
<a id="reload" href="filename.htm" style="display:none">reload...</a>
<input type="button" value="关闭" onclick="window.close()">
也要配合<base target="_self">Q不然会(x)打开一个新的IEH口Q然后再x的?/p>
(作者语Q本来想用一问一{Ş式来写的Q但是我想不个怎么问,所以只好这样了?
q个东西比较ȝQ我改了好几ơ了不是没办法说明白(语文水^来差?Q只好用个例子说明了?br /> 例子Q?br /> 现在需要在一个showModalDialog(或showModelessDialog)里读取或讄一个变量var_name
window.showModalDialog("filename.htm",var_name)
//传递var_name变量
在showModalDialog(或showModelessDialog)d和设|时Q?br /> alert(window.dialogArguments)//dvar_name变量
window.dialogArguments="oyiboy"http://讄var_name变量
q种方式是可以满的Q但是当你想在操作var_name同时再操作第二个变理var_id时呢Q就无法再进行操作了。这是q种传递方式的局限性?br />
以下是我使用的传递方式:(x)
window.showModalDialog("filename.htm",window)
//不管要操作什么变量,只直传递主H口的window对象
在showModalDialog(或showModelessDialog)d和设|时Q?br /> alert(window.dialogArguments.var_name)//dvar_name变量
window.dialogArguments.var_name="oyiboy"http://讄var_name变量
alert(window.dialogArguments.var_id)//dvar_id变量
window.dialogArguments.var_id="001"http://讄var_id变量
因ؓ(f)光说很费Ԍ我就L(fng)懒,直接用代码来说了Q如果不明白的话那就直接来信(oyiboy#163.net(使用时请?Ҏ(gu)@))问我吧?/p>
var s2=showModelessDialog('about:blank',window,"dialogTop:200px;dialogLeft:300px"Q //打开被控制窗?/p>
//操作位置数据Q因为窗口的位置数据?xxxpx"方式的,所以需要这L(fng)一个特D操作函数?br /> function countNumber(A_strNumber,A_strWhatdo)
{
A_strNumber=A_strNumber.replace('px','')
A_strNumber-=0
switch(A_strWhatdo)
{
case "-":A_strNumber-=10;break;
case "+":A_strNumber+=10;break;
}
return A_strNumber + "px"
}
</script>
<input type="button" onclick="window.dialogArguments.s2.dialogTop=countNumber(window.dialogArguments.s2.dialogTop,'-')" value="上移">
<input type="button" onclick="window.dialogArguments.s2.dialogLeft=countNumber(window.dialogArguments.s2.dialogLeft,'-')" value="左移">
<input type="button" onclick="window.dialogArguments.s2.dialogLeft=countNumber(window.dialogArguments.s2.dialogLeft,'+')" value="右移">
<input type="button" onclick="window.dialogArguments.s2.dialogTop=countNumber(window.dialogArguments.s2.dialogTop,'+')" value="下移">
H口命名方式Qvar s1=showModelessDialog('控制.htm',window,"dialogTop:1px;dialogLeft:1px"Q?br /> 变量讉K方式Qwindow.dialogArguments.s2.dialogTop
if (str.indexOf("&")>0){
para = parastr.split("&");
for(i=0;i<para.length;i++) {
tempstr1 = para[i];
pos = tempstr1.indexOf("=");
//document.write (tempstr1.substring(0,pos));
document.write ("<br>参数"+i+":"+tempstr1.substring(0,pos));
document.write ("{于:"+tempstr1.substring(pos+1));
}
}
</script>
<script language="javascript">
function inhtm() {
var n = document.location.search.substring(1);
var s = n.substring(n.indexOf("=")+1, n.length);
document.write ("ID=:"+s);
}
</script>
使用户不能更改输入框中的内容Q?/font>
<input type=text value="中国" onfocus=this.blur()>
<input type=text value="中国" readonly> //只读
<input type=text value="中国" disabled> //用