<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 165, comments - 198, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    create div

    Posted on 2008-09-15 01:02 G_G 閱讀(434) 評論(0)  編輯  收藏 所屬分類: javascript
    直接 運行 div_show_drag.rar
    http://m.tkk7.com/Files/Good-Game/div_Show_drag.rar

    html test
    <html>
    <head>

    <script?type="text/javascript"?src="showDivUtil.js"></script>

    </head>

    <body>

    <input?type="button"?id="_in"?value="google-baidu"?onclick="test();"/>
    <div?id='_div'?/>
    <script?language="javascript">
    /*api說明
    ????ShowDiv(?源element?,?是否使用現有?div?)
    ????????源element,是否使用現有?div?都可為null?;
    */
    var?ediv?=?new?ShowDiv('_in',null);

    function?test(){
    ????
    if(?!?ediv.isShow?){
    ????????
    // tdiv[X,Y,H,W]準備展現div set->tdiv.X = ..? ? ,
    ??????? // tsubEle[X,Y,H,W]
    ??????? // 源ele大小位置??,tscreen[
    screenH,screenW]屏幕長寬
    ????????ediv.setLocation?=?function(tdiv,tsubEle,tscreen){
    ????????????
    /*??居中展現
    ?????????????tdiv.W?=200?;
    ?????????????tdiv.H?=?300?;
    ?????????????tdiv.X?=?tscreen.screenW/2-tdiv.W/2?;
    ?????????????tdiv.Y?=?tscreen.screenH/2-tdiv.H/2?;
    ????????????
    */

    ?????????????
    /*??根據?tsubEle?位置?左顯示
    ????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????
    */

    ??????????????
    /*??根據?tsubEle?大小??左長條?顯示?
    ?????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ?????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????
    */
    ????????????
    ????????
    ??????????????
    /*??根據?tsubEle?大小??下長條?顯示
    ?????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ?????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????tdiv.H?=?200?;
    ?????????????tdiv.W?=?tsubEle.W?;
    ?????????????
    */
    ????????????
    ????????????
    /*??..?等等?自己嘗試吧*/
    ????????????tdiv.innerHTML?
    =?"<li>google</li><li>baidu</li>"?;
    ????????????
    //可以參考?
    ????????????Drag.init(tdiv);
    ????????}????
    ????????ediv.setStyle('background
    -color:#F4F4F4;');
    ????????ediv.show();
    ????}
    else{
    ????????ediv.close();
    ????????
    //ediv.delete();
    ????}
    }

    </script>
    </body>
    </html>



    showDivUtil.js

    /*
    * Skynet
    *? 2008-9-15 00:56
    *?? liukaiyi@gmail.com
    */

    function?ShowDiv(subEle,ediv){
    ????
    //public?
    ????this.style??;
    ????
    this.isShow?=?false?;

    ????
    //private?
    ????this._div??;
    ????
    this._subEle??;
    ????
    this._subEle??;


    ????????
    if(?typeof?ediv?==?"undefined"?||?ediv?==?null)?
    ????????????
    this._div=document.createElement("div");
    ????????
    else?if(?typeof?ediv?==?"string")?
    ????????????
    this._div=document.getElementById(ediv);????
    ????????
    else?if(??/object/.test(typeof?ediv)?)
    ????????????
    this._div=?ediv?;
    ????????
    ????????
    if(?typeof?subEle?==?"string")?
    ????????????
    this._subEle=document.getElementById(subEle);????
    ????????
    else?if(??/object/.test(typeof?subEle)?)
    ????????????
    this._subEle=?subEle?;

    }

    ????
    //外置方法?x?,?y?,w?,?h?,?div
    ????ShowDiv.prototype.setLocation?=?new?Function()?;

    ????
    //設置?div?樣式
    ????ShowDiv.prototype.setStyle=function(styleStrOrObj){
    ????????
    this.style=this._div.style?;
    ????????
    if(?typeof?styleStrOrObj?==?"string"){
    ????????????
    var?strs?=?styleStrOrObj.split(/;/)?;
    ????????????
    for(var?i=0;i<strs.length;i++){
    ????????????????
    var?key?=?strs[i].split(/:/)[0];
    ????????????????
    var?value?=?strs[i].split(/:/)[1];
    ????????????????
    var?_s?=?key.indexOf("-")?;
    ????????????????
    if(?_s>0)?
    ????????????????????key
    =key.substring(0,_s)+key.substring(_s+1,_s+2).toLocaleUpperCase()+key.substring(_s+2,key.length);
    ????????????????
    if(?key!=null&&key!=''&&key!='?'?){
    ????????????????????eval(?'
    this._div.style.'+key+'="'+value+'"'?);
    ????????????????}
    ????????????}
    ????????}
    else?if(??/object/.test(typeof?styleStrOrObj)?)?{
    ????????????
    this._div.style?=?styleStrOrObj?;
    ????????}
    ????????
    if(this._div.style.position==null?||?this._div.style.position=="")
    ????????????
    this._div.style.position="absolute";
    ????}
    ????
    ????ShowDiv.prototype.show
    =function(){
    ????????
    if(?typeof?this._subEle?!=?"undefined"?||?this._subEle?!=?null){
    ????????????
    this._subEle.Y?=?getElementPos(this._subEle).y;
    ????????????
    this._subEle.X?=?getElementPos(this._subEle).x?;
    ????????????
    this._subEle.W?=?this._subEle.offsetWidth?;
    ????????????
    this._subEle.H?=?this._subEle.offsetHeight?;
    ????????}
    ????????
    //this._div.Y?=?sset
    ????????//this._div.X?=?sset
    ????????this._div.W?=?parseInt(?this._div.style.width?);
    ????????
    this._div.H?=?parseInt(?this._div.style.height?);
    ????????
    ????????
    this.setLocation(this._div,this._subEle,{screenW:document.body.clientWidth,screenH:document.body.clientHeight});
    ????????
    this._div.style.left?=?this._div.X??;
    ????????
    this._div.style.top?=?this._div.Y?;
    ????????
    ????????
    if(?this._div.W?&&?this._div.H?){
    ????????????
    this._div.style.width?=?this._div.W?;
    ????????????
    this._div.style.height?=?this._div.H?;
    ????????}
    ????????document.body.appendChild(
    this._div);
    ????????
    this.isShow?=?true?;
    ????}

    ????ShowDiv.prototype.close
    =function(){
    ????????document.body.removeChild(
    this._div);?
    ????????
    this.isShow?=?false?;
    ????}

    ?????ShowDiv.prototype.
    delete=function(){
    ????????document.body.removeChild(
    this._div);?
    ????????
    this._div?=?null?;
    ????????
    this.isShow?=?false?;
    ????}

    ?
    //得到 Element 位置
    //?說明:用?Javascript?獲取指定頁面元素的位置
    //
    ?整理:http://www.codebit.cn
    //
    ?來源:YUI?DOM
    function?getElementPos(el)?{
    ????
    var?ua?=?navigator.userAgent.toLowerCase();
    ????
    var?isOpera?=?(ua.indexOf('opera')?!=?-1);
    ????
    var?isIE?=?(ua.indexOf('msie')?!=?-1?&&?!isOpera);?//?not?opera?spoof
    ????if(el.parentNode?===?null?||?el.style.display?==?'none'){
    ????????
    return?false;
    ????}
    ????
    var?parent?=?null;
    ????
    var?pos?=?[];
    ????
    var?box;

    ????
    if(el.getBoundingClientRect){
    ????
    //?IE?
    ????????box?=?el.getBoundingClientRect();
    ????????
    var?scrollTop?=?Math.max(document.documentElement.scrollTop,?document.body.scrollTop);
    ????????
    var?scrollLeft?=?Math.max(document.documentElement.scrollLeft,?document.body.scrollLeft);
    ????????
    return?{x:box.left?+?scrollLeft,?y:box.top?+?scrollTop};
    ????}
    else?if(document.getBoxObjectFor){
    ?????
    //?gecko
    ????????box?=?document.getBoxObjectFor(el);
    ????????
    var?borderLeft?=?(el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
    ????????
    var?borderTop?=?(el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
    ????????pos?
    =?[box.x?-?borderLeft,?box.y?-?borderTop];
    ????}
    else?{
    ?????
    //?safari?&?opera
    ????????pos?=?[el.offsetLeft,?el.offsetTop];
    ????????parent?
    =?el.offsetParent;
    ????????
    if?(parent?!=?el)?{
    ????????????
    while?(parent)?{
    ????????????????pos[
    0]?+=?parent.offsetLeft;
    ????????????????pos[
    1]?+=?parent.offsetTop;
    ????????????????parent?
    =?parent.offsetParent;
    ????????????}
    ????????}
    ?????????
    if?(ua.indexOf('opera')?!=?-1||?(?ua.indexOf('safari')?!=?-1?&&?el.style.position?==?'absolute'?)){
    ????????????pos[
    0]?-=?document.body.offsetLeft;
    ????????????pos[
    1]?-=?document.body.offsetTop;
    ????????}
    ????}
    ?
    ????
    if?(el.parentNode)?{?parent?=?el.parentNode;?}
    ????
    else?{?parent?=?null;?}
    ?
    ?
    ????
    //?account?for?any?scrolled?ancestors
    ?????while?(parent?&&?parent.tagName?!=?'BODY'?&&?parent.tagName?!=?'HTML'){?????
    ????????pos[
    0]?-=?parent.scrollLeft;
    ????????pos[
    1]?-=?parent.scrollTop;
    ????????
    if?(parent.parentNode)?{?parent?=?parent.parentNode;?}
    ????????
    else?{?parent?=?null;?}
    ????}
    ????
    return?{x:pos[0],?y:pos[1]};
    }?




    主站蜘蛛池模板: 无码乱肉视频免费大全合集 | 亚洲最大的黄色网| 95老司机免费福利| 亚洲日本va午夜中文字幕一区| 在线观看人成视频免费无遮挡| 久久久久亚洲AV成人网人人网站 | 免费人成在线观看网站| 国产AV无码专区亚洲A∨毛片| 黄色网站软件app在线观看免费| 国产亚洲成av人片在线观看| 青青青国产手机频在线免费观看| 亚洲AV无码不卡无码| 日韩精品无码一区二区三区免费| 久久狠狠高潮亚洲精品| 一个人免费观看在线视频www| 一本天堂ⅴ无码亚洲道久久| 国产免费怕怕免费视频观看| 9久热精品免费观看视频| 亚洲AV无码精品色午夜果冻不卡 | 亚洲av最新在线网址| 亚洲毛片免费视频| 亚洲国产av玩弄放荡人妇| 亚洲av无码乱码在线观看野外 | 国产精品免费观看久久| 香港经典a毛片免费观看看| 中国亚洲女人69内射少妇| 91精品国产免费网站| 亚洲AV无码片一区二区三区| 国产偷国产偷亚洲高清日韩 | 在线观看免费亚洲| 国产精品免费看久久久香蕉| 亚洲色图校园春色| 青青青国产色视频在线观看国产亚洲欧洲国产综合 | 性xxxx视频免费播放直播| 亚洲人成网站看在线播放| 亚洲VA综合VA国产产VA中| 久9这里精品免费视频| 亚洲国产精品无码久久| 亚洲精品狼友在线播放| 成年在线网站免费观看无广告| 国产裸体美女永久免费无遮挡|