Div iFrame 做的面向对象小窗口 1.0.0 全部代码才12.9K

Div iFrame 做的面向对象小窗口 1.0.0

网上下载及试用: http://www.minierp.cn/soft/xwin/demo.html
/*

@################################
@版本 : 1.0.0

@作者 : ElvenHu   2008-01-23 修改   
@ 功能:Div iFrame 做的面向对象小窗口
@ 网址:http://www.minierp.cn    http://bbs.minierp.cn
@使用方法:     ElvenHu 2008-01-23
    1.    x = new xWin('x');   // x 是实例名  = new xWin('x')参数x 要和实例名一样 !
    2.    x.skins='xwin/';        //skins 默认为 当前目录下的xwin目录 可以指定目录
    3.    x.open(title,url,left,top,width,heigth);  //打开窗口,title 窗口名称 url 要打开的网址 left 窗口最左边 top 窗口顶端 width窗口宽度 heigth窗口高度
    4. self.parent.returnVal()    在窗口中打开的网页如要返回数据 在子网页中写一个函数 在函数中执行这一句 ! 其中  returnVal() 为主网页中的函数
@################################

*/


function   xWin(obj) {
this.obj            =obj;
this.topobj    ='win_top';
this.left        =100;
this.top            =100;
this.width        =200;
this.height    =100;
this.minrestore=0;
this.url            =''
this.skins        ='xwin/'
}
;

var  xWin_ie5;

var  xWin_ns6;
var  dragapproved;
xWin_ie5 
=  document.all  &&  document.getElementById;

xWin_ns6 
=  document.getElementById  &&   ! document.all;
// 以下三行是因为拖动时鼠标动太快跑到 子窗口不能拖动的问题
var  xWin_drag_id = '' ;
var  xWin_fram_id = '' ;
var  xWin_cont_id = '' ;
xWin.prototype.init
= function () {


this. xWin_name =this.obj;    

this.symbol_img = this.skins + "symbol.gif";

this.max_img = this.skins + "max.gif";

this.restore_img = this.skins + "min.gif";

this.close_img = this.skins + "close.gif";

this.help_img = this.skins + "help.gif";

this.title_img = this.skins + "title.gif";

this.bottom_img = this.skins + "bottom.gif";

this.intern_img = this.skins + "intern.gif";

this.grip_img = this.skins + "grip.gif";

this.forward_img = this.skins + "forward.gif";

this.back_img = this.skins + "back.gif";

this.border_img = this.skins + "border.gif";

this.loading_page = this.skins + "loading.htm";

//this.xWin_ie5 = document.all && document.getElementById;

//this.xWin_ns6 = document.getElementById && !document.all;

this.win_frame = "<div id='"+this.xWin_name+"_xWin_win' style='position:absolute;z-index:100; width: 420px; height: 350px ;left:10px;top:10px;font-size:12px; display:none ' onselectstart='return false'> ";

this.win_frame += "<div> ";

this.win_frame += "<table width='100%'  border='0' cellspacing='0' cellpadding='0'> ";

this.win_frame += "    <tr> ";

this.win_frame += "        <td width='19' height='18'><a href='javascript:"+this.obj+".xwin_reload("+this.xWin_name+"_xWin_frame)' title='重新载入当前网页' ><img src='" + this.symbol_img + "' width='19' height='18' border='0'  /></a></td> ";

this.win_frame += "        <td width='5' style='background: url(" + this.title_img + "); padding:0px'></td><td style='background: url(" + this.title_img + "); padding:0px' οnmοusedοwn='"+this.obj+".initialize_drag(event)' οndblclick='"+this.obj+".minisize()'><font color='#333333'><div id='"+this.xWin_name+"_title_msg_layer'><strong>"+this.title+"</strong></div></font> ";

this.win_frame += "        </td> ";

this.win_frame += "    <!--    <td style='background: url(" + this.title_img + "); padding:0px' οnmοusedοwn=='"+this.obj+".initialize_drag(event)'></td>--> ";

this.win_frame += "    <td width='57' style='cursor:default; ' align='center' valign='top' nowarp>";

this.win_frame += "<a href='javascript:"+this.obj+".xWinAbout()' title='关于本程式' ><img src='" + this.help_img + "' width='19' height='18' border='0' /></a>";

this.win_frame += "<a href='javascript:"+this.obj+".maxsize()' title='放大窗口' ><img src='" + this.max_img + "' id='"+this.xWin_name+"_max_button_name' width='19' height='18' border='0' /></a>";

this.win_frame += "<a href='javascript:"+this.obj+".closeit()' title='关闭窗口' ><img src='" + this.close_img + "'  width='19' height='18' border='0' /></a>";

this.win_frame += "</td> ";

this.win_frame += "    </tr> ";

this.win_frame += "</table> ";

this.win_frame += "</div> ";

this.win_frame += "<div id='"+this.xWin_name+"_xWin_content' align=center style='width:100%;  margin: 0px;background-color: #ffffff;    MOZ-OPACITY:0.50;FILTER :  Alpha(opacity=100);'> ";

this.win_frame += "<table style='width:100%; height:100%; margin: 0px;' border='0' cellpadding='0' cellspacing='0'> ";

this.win_frame += "    <tr> ";

this.win_frame += "        <td width='1'><img src='"+ this.border_img + "' id='"+this.xWin_name+"_border_img_name1' border='0' style='border:0px; width:1px; height:317px; margin: 0px;' /></td> ";

this.win_frame += "        <td> ";

this.win_frame += "        <iframe id='"+this.xWin_name+"_xWin_frame'  name='"+this.xWin_name+"_xWin_frame' src='" + this.loading_page + "' frameborder=0 noresize style='width:100%; height:100%;background-color: #ffffff;color: #333;margin: 0px; padding: 0px;border:0px '></iframe> ";

this.win_frame += "        </td> ";

this.win_frame += "        <td width='1'><img src='" + this.border_img + "' id='"+this.xWin_name+"_border_img_name2' border='0' style='border:0px; width:1px; height:317px; margin: 0px;' /></td> ";

this.win_frame += "    </tr> ";

this.win_frame += "</table> ";

this.win_frame += "</div> ";

this.win_frame += "<div align='center' style='width:100%;height:15px;background: url(" + this.bottom_img + ");' onselectstart='return false'> ";

this.win_frame += "<table width='100%'  border='0' cellspacing='0' cellpadding='0'> ";

this.win_frame += "    <tr> ";

this.win_frame += "        <td width='19'><img src='" + this.intern_img + "' width='28' height='15' border='0' /></td> ";

this.win_frame += "            <td width='42'><a href='javascript:"+this.obj+".xwin_back("+this.xWin_name+"_xWin_frame);' title='后退' ><img src='" + this.back_img + "' width='19' height='13' border='0'/></a><a href='javascript:"+this.obj+".xwin_foward("+this.xWin_name+"_xWin_frame);' title='前进' ><img src='" + this.forward_img + "' width='19' height='13' border='0' /></a></td> ";

this.win_frame += "        <td><div id='"+this.xWin_name+"_size_info_layer'>&nbsp;</div></td> ";

this.win_frame += "        <td>&nbsp;</td> ";

this.win_frame += "        <td width='19'><a href='javascript:vaid(0)' οnmοusedοwn='return "+this.obj+".initialize_resize(event)' title='关闭窗口' ><img src='" + this.grip_img + "' width='19' height='15' border='0' style='cursor:nw-resize' title='改变窗口大小'  /></td> ";

this.win_frame += "    </tr> ";

this.win_frame += "</table> ";

this.win_frame += "</div> ";

this.win_frame += "</div> ";

this.win_frame += "<div id='"+this.xWin_name+"_xWin_win_border' style='position:absolute;z-index:100;width:0px;height:0px;display:none'></div> ";


}
;

xWin.prototype.open
= function (title,url,l,t,w,h) {
this.url            =url;
this.title        =title;
this.left        =l;
this.top            =t;
this.width        =w;
this.height    =h;
this.init();
var node = document.createElement("DIV");
this.topobj=this.obj+'_show_top';
    node.id
=this.topobj;
node.innerHTML 
= this.win_frame;
document.body.appendChild(node);

this.xWin_win_id                 = document.getElementById(this.xWin_name+"_xWin_win");
this.xWin_content_id         = document.getElementById(this.xWin_name+"_xWin_content");

this.title_msg_layer_id         = document.getElementById(this.xWin_name+"_title_msg_layer");

this.xWin_frame_id             = document.getElementById(this.xWin_name+"_xWin_frame");

this.max_button_name_id         = document.getElementById(this.xWin_name+"_max_button_name");

this.border_img_name1_id         = document.getElementById(this.xWin_name+"_border_img_name1");

this.border_img_name2_id     = document.getElementById(this.xWin_name+"_border_img_name2");

this.xWin_win_border_id     = document.getElementById(this.xWin_name+"_xWin_win_border");    

this.size_info_layer_id         =  document.getElementById(this.xWin_name+"_size_info_layer");    


this.xWin_win_id.style.display = '';
this.xWin_frame_id.src = this.url;

this.ChangeSize(this.left,this.top,this.width,this.height);

}

xWin.prototype.ChangeSize
= function (l,t,w,h)
if(l >0 ) {
this.xWin_win_id.style.left = l;
}
else{
this.xWin_win_id.style.left = 100;
}

if(t>0){
this.xWin_win_id.style.top  = t;
}
else{
this.xWin_win_id.style.top  = 100;
}


if(w > 100 ) {

this.xWin_win_id.style.width = w;

}
else{

this.xWin_win_id.style.width = 350;

}


if(h > 30 ) {

this.xWin_win_id.style.height = this.border_img_name1_id.style.height = this.border_img_name2_id.style.height = this.xWin_frame_id.style.height = h;

}
else{

this.xWin_win_id.style.height = this.border_img_name1_id.style.height = this.border_img_name2_id.style.height = this.xWin_frame_id.style.height = 100;


}


this.size_info_layer_id.innerHTML = '<font style="font-size:11px;font-family:Courier New"> left:'+ remove_units(this.xWin_win_id.style.left)+' top:'+ remove_units(this.xWin_win_id.style.top)+'  size: ' + remove_units(this.xWin_win_id.style.width) + 'x' + remove_units(this.xWin_win_id.style.height) + '</font>';

}



function  remove_units(elem) {

return(parseInt(elem.replace(/px/g,"")));            

}


xWin.prototype.maxsize
= function () {

if (this.minrestore == 0){

this.minrestore = 1//minisize window

this.max_button_name_id.setAttribute("src"this.restore_img);

this.max_button_name_id.setAttribute("title"'还原窗口');
l
=1;
t
=1;

w     
= xWin_ns6 ? window.innerWidth - 5 : iecompattest().clientWidth - 5;

h     
= xWin_ns6 ? window.innerHeight - 40 : iecompattest().clientHeight - 20;

this.ChangeSize(l,t,w,h);

}


else{

this.minrestore=0//restore window

this.max_button_name_id.setAttribute("src",this.max_img);

this.max_button_name_id.setAttribute("title"'放大窗口');

this.ChangeSize(this.left,this.top,this.width,this.height);

}


}



xWin.prototype.xWinAbout
= function () {
str 
= "ElvenHu (http://bbs.minierp.cn) 版权所有";

alert(str);

}

xWin.prototype.close
= function () {
this.closeit();
}

xWin.prototype.closeit
= function () {
this.xWin_win_id.style.display ="none";
 document.getElementById(
this.topobj).innerHTML ='';
//eval(this.topobj).innerHTML ='';
}


xWin.prototype.initialize_drag
= function (e) {
var evt = xWin_ns6 ? e : event;
offsetx 
= evt.clientX;

offsety 
= evt.clientY;

tempx 
= parseInt(this.xWin_win_id.style.left);

tempy 
= parseInt(this.xWin_win_id.style.top);


dragapproved 
= true;
xWin_drag_id
=this.xWin_win_id;
xWin_fram_id
=this.xWin_frame_id;
xWin_cont_id
=this.xWin_content_id;

//xWin_cont_id.style.display = 'none';  //这个改动影响到子窗口大小;

xWin_fram_id.style.display 
= 'none';


document.body.style.cursor 
= 'move';

document.onmousemove 
= this.drag_drop;  //移动还没有完成  2008-01-24

document.onmouseup         
= this.drag_drop_stop;

}



xWin.prototype.drag_drop
= function (e) {
if(dragapproved){

var evt = xWin_ns6 ? e : event;

xWin_drag_id.style.left 
= tempx + evt.clientX - offsetx + "px";

xWin_drag_id.style.top 
= tempy + evt.clientY - offsety + "px";

}


return false;

}


xWin.prototype.drag_drop_stop
= function (e) {

if(dragapproved){

//xWin_cont_id.style.display = '';

xWin_fram_id.style.display 
= '';
}

dragapproved 
= false;
xWin_cont_id 
= '';

xWin_fram_id
= '';
document.body.style.cursor 
= 'default';
document.onmousemove
=null;
document.onmouseup        
=null;

}

xWin.prototype.xwin_back
= function (framid) {
    framid.history.back()
}

xWin.prototype.xwin_foward
= function (framid) {
framid.history.go(
1)
}

xWin.prototype.xwin_reload
= function (framid) {
framid.location.reload(
true);
}


// resize===<<<
var  xWin_border_id;
var  xWin_resize_id
var  dragresized;
var  xWin_name;
xWin.prototype.initialize_resize
= function (e) {
    
var evt = xWin_ns6 ? e : event;
    xWin_name
=eval(this.obj);
    xWin_resize_id
=this.xWin_win_id;
    xWin_border_id
=this.xWin_win_border_id;

    xWin_border_id.style.left     
= this.xWin_win_id.style.left;

    xWin_border_id.style.top         
=this.xWin_win_id.style.top;

    xWin_border_id.style.width     
= this.xWin_win_id.style.width;

    xWin_border_id.style.height 
=this.xWin_win_id.style.height;



    click_x 
= evt.clientX;

    click_y 
= evt.clientY;

    evt_width         
= click_x - remove_units(this.xWin_win_id.style.left);

    evt_height     
= click_y - remove_units(this.xWin_win_id.style.top);

    dragresized 
= true;

    xWin_border_id.style.display 
= '';

    xWin_border_id.style.border
='1px #808080 solid';

    document.body.style.cursor 
= 'nw-resize';

    document.onmousemove 
= drag_resize;

    document.onmouseup 
= drag_resize_stop;

    
return false;

}


function  drag_resize(e) {

    
if(dragresized){

            evt 
=xWin_ns6 ? e : event;

        w 
= evt_width + (evt.clientX - click_x);

        h 
= evt_height + (evt.clientY - click_y);

        
if(w > 0 ) {

            xWin_border_id.style.width 
= w;

        }


        
if(h > 0 ) {

            xWin_border_id.style.height 
= h;

        }


    }


    document.body.style.cursor 
= 'nw-resize';

    
return false;

}


function  drag_resize_stop(e) {

    dragresized
=false;

    xWin_name.ChangeSize(remove_units(xWin_border_id.style.left),remove_units(xWin_border_id.style.top),remove_units(xWin_border_id.style.width), remove_units(xWin_border_id.style.height));

    xWin_border_id.style.border
='0px';

    xWin_border_id.style.display 
= 'none';
        xWin_resize_id
='';
    xWin_border_id
='';

    document.body.style.cursor
='default';

    document.onmousemove
=null;
    document.onmouseup     
= null;

}


// resize===>>>

    

xWin.prototype.no
= function () {
str 
= "有些功能还没有完成! 您可以上 http://bbs.minierp.cn 看看,有没有新的版本!!";

alert(str);
}

// >>>drag move
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是创建微信小程序的 Java 代码示例: // 定义一个微信小程序类 public class WechatMiniProgram { // 小程序名称 private String name; // 小程序ID private String id; // 小程序版本号 private String version; // 构造函数 public WechatMiniProgram(String name, String id, String version) { this.name = name; this.id = id; this.version = version; } // 获取小程序名称 public String getName() { return this.name; } // 获取小程序ID public String getId() { return this.id; } // 获取小程序版本号 public String getVersion() { return this.version; } // 设置小程序名称 public void setName(String name) { this.name = name; } // 设置小程序ID public void setId(String id) { this.id = id; } // 设置小程序版本号 public void setVersion(String version) { this.version = version; } // 打印小程序信息 public void printProgramInfo() { System.out.println("小程序名称:" + this.name); System.out.println("小程序ID:" + this.id); System.out.println("小程序版本号:" + this.version); } // 入口函数 public static void main(String[] args) { // 创建一个微信小程序对象 WechatMiniProgram miniProgram = new WechatMiniProgram("小程序1", "wx123456", "1.0.0"); // 打印小程序信息 miniProgram.printProgramInfo(); // 更新小程序信息 miniProgram.setName("小程序2"); miniProgram.setId("wx789012"); miniProgram.setVersion("1.1.0"); // 再次打印小程序信息 miniProgram.printProgramInfo(); } } 这个示例代码演示了如何使用Java语言创建一个简单的微信小程序类,并定义了小程序名称、ID、版本号等属性和方法。在入口函数中,我们创建了一个微信小程序对象,打印了小程序的信息,然后更新了小程序的信息,并再次打印了小程序的信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值