首页 新闻 会员 周边 捐助

JS IE6 和 搜狗浏览器兼容性问题 求解

0
悬赏园豆:20 [已解决问题] 解决于 2012-12-10 21:15

function Dialog() {
    this.prtObj = null;
    this.obj = null;
    this.top = null;
    this.left = null;
    this.right = null;
    this.bottom = null;
    this.minHeight = null;
    this.minWidth = null;
    this.opacity = null;
    this.childPosition = null;
}
Dialog.prototype = {
    init: function() {
        // var prt = $get('body');
        var prt = document.body;
        dialog.prtObj = $crt('DIV');
        dialog.prtObj.id = "prtDiaglog";
        dialog.prtObj.style.width = document.body.clientWidth.toString() + 'px';
        dialog.prtObj.style.height = document.body.clientHeight.toString() + 'px';
        dialog.prtObj.style.left = 0;
        dialog.prtObj.style.top = 0;
        dialog.prtObj.style.background = "#000000";
        dialog.prtObj.style.filter = "alpha(opacity=80)";
        //设置透明图
        if (dialog.opacity == null) {
            dialog.prtObj.style.opacity = 0.5;
        }
        else {
            dialog.prtObj.style.opcity = dialog.opcity;
            dialog.prtObj.style.zIndex = 100;
        }
        dialog.obj = $crt("DIV");
        dialog.obj.id = 'dialog';
        dialog.obj.style.minHeight = dialog.minHeight;
        dialog.obj.style.minWidth = dialog.minWidth;

        //        dialog.obj.style.position = dialog.position;
        if (dialog.childPosition == 'absolute') {
            dialog.obj.style.position = 'absolute';
            dialog.DialogAlign();

        }
        else {
            dialog.obj.style.position = dialog.childPosition;
        }
        if (dialog.left != null) {
            dialog.obj.style.left = dialog.left.toString() + 'px';
        }
        if (dialog.top != null) {
            dialog.obj.style.top = dialog.top.toString() + 'px';
        }
        $app(dialog.prtObj, prt);
    },
    DOpen: function(obj) {
        dialog.childPosition = 'absolute';
        dialog.minWidth = '200px';
        dialog.minHeight = '120px';
        dialog.init();
        var prt = document.body;
        dialog.obj.style.backgroundImage = 'url("/images/items/pic_011.gif")';
        dialog.obj.style.backgroundPosition = "-150px -135px";
        dialog.obj.style.zIndex = 1000;
        //$remove(obj);
        $app(dialog.obj, prt);
    },
    DClose: function(obj) {
        $remove($get("dialog"));
        $remove($get("prtDiaglog"));
    },
    ClickOpenDiaglog: function(obj) {
        dialog.childPosition = 'relative';
        dialog.left = '250';
        dialog.top = '-500';
        dialog.init();
        dialog.obj.style.zIndex = 1000;
        dialog.obj.style.width = '368px';
        dialog.obj.style.height = '320px';

        dialog.AddStyle();
        $app(dialog.obj, obj.parentNode.parentNode);
    },
    openItemSelectDialog: function(obj) {
        dialog.childPosition = 'relative';
        dialog.left = '170';
        dialog.top = '-380';
        dialog.init();
        dialog.obj.style.zIndex = 1000;
        dialog.obj.style.width = '500px';
        dialog.obj.style.height = 'auto';
        dialog.obj.style.clear = 'both';
        dialog.AddStyle();
        $app(dialog.obj, obj.parentNode.parentNode);
    },
    DialogAlign: function() {
        var w = window.screen.width;
        var h = window.screen.height;
        if (dialog.obj.style.width != '') {
            var areaW = dialog.obj.style.width;
            areaW = areaW.toString().subString(0, dialog.obj.style.width.length - 2);
        }
        else {
            var areaW = dialog.obj.style.minWidth;
            areaW = areaW.toString().substring(0, dialog.obj.style.minWidth.length - 2);
        }
        if (dialog.obj.style.height != '') {
            var areaH = dialog.obj.style.height;
            areaH = areaH.toString().subString(0, dialog.obj.style.height.length - 2);
        }
        else {
            var areaH = dialog.obj.style.minHeight;
            areaH = areaH.toString().substring(0, dialog.obj.style.minHeight.length - 2);
        }
        if ((w > areaW)) { dialog.left = Math.floor((w - areaW) / 2); }
        if (h > areaH) { dialog.top = Math.floor((h - areaH) / 3); }
    },
    AddStyle: function() {
        var diaglogTop = $crt('Div');
        diaglogTop.id = 'diaglogtop';

        var dialogTopleft = $crt("div");
        dialogTopleft.className = 'DialogTopPon';
        dialogTopleft.id = 'left';
        var dialogTopRight = $crt("div");
        dialogTopRight = $crt("div");
        dialogTopRight.className = 'DialogTopPon';
        dialogTopRight.id = "right";
        var dialogTopMiddle = $crt("div");
        dialogTopMiddle.className = 'DialogTopMiddle';
        $app(dialogTopleft, diaglogTop);
        $app(dialogTopMiddle, diaglogTop);
        $app(dialogTopRight, diaglogTop);
        var closeDiaglog = $crt('img');
        closeDiaglog.src = "/images/Diaglog/pic_002.png";
        closeDiaglog.id = 'closeDiaglog';
        $setAttr(closeDiaglog, 'onclick', 'javascript:dialog.DClose(this,event);')
        $app(closeDiaglog, diaglogTop);
        $app(diaglogTop, dialog.obj);
        var diaglogMid = $crt("Div");
        diaglogMid.id = 'diaglogMid';
        $app(diaglogMid, dialog.obj);
        var diaglogBottom = $crt('Div');
        diaglogBottom.id = 'diaglogButtom';
        var Btnsumit = $crt("img");
        Btnsumit.id = 'btnSubmit';
        Btnsumit.src = "/images/Diaglog/pic_010.png";
        $app(Btnsumit, diaglogBottom);
        $app(diaglogBottom, dialog.obj);
    }

 

};
var dialog = new Dialog();

在Firefox 和 IE 8  下 关闭按钮能用 ,在 搜狗 和 IE 浏览器下,关闭按钮失效!!!!

CDFanFan的主页 CDFanFan | 初学一级 | 园豆:3
提问于:2012-05-25 18:59
< >
分享
最佳答案
0

设置.style.display ="none";

 

DClose: function(obj) {
        $remove($get("dialog"));
        $remove($get("prtDiaglog"));
    },
这是你关闭的方法吗?
收获园豆:20
icepy | 小虾三级 |园豆:587 | 2012-05-26 22:44

对哈,不过问题已经解决了,原来是 onclick 不能用 obj.setAttribute("onclick","javascript:dialog.Dclose()");

可以直接用obj.onclick=function(){dialog.Dclose();};

CDFanFan | 园豆:3 (初学一级) | 2012-05-26 22:48

@CDFanFan: 你用改变属性的方式,这个不是很好,你是用的原始事件,直接写在标签里的?

icepy | 园豆:587 (小虾三级) | 2012-05-26 22:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册