简体   繁体   English

IE8与Chrome,Safari和IE9的兼容性问题

[英]Compatibility issues with IE8 vs Chrome, Safari, and IE9

This could be a challenging one! 这可能是一个挑战!

I'm very proficient in AJAX and JavaScript even writing OOP JS apps. 我非常精通AJAX和JavaScript,甚至编写OOP JS应用程序。 So you can imagine my frustration when I build a page that works flawlessly in IE7, 8, Opera, FF4. 因此,当我构建一个在IE7、8,Opera和FF4中可完美运行的页面时,您可以想象我的沮丧。 I mean, unless the world has changed, IE and FF were all you ever needed, really, for compatibility testing.... right?? 我的意思是,除非世界改变了,否则兼容性测试实际上只需要IE和FF。

WRONG (apparently) 错误(显然)

I have a complicated js app that works great, as I said. 正如我所说的,我有一个运行良好的复杂js应用程序。 But if fails in Chrome and Safari. 但是如果在Chrome和Safari中失败。 The scripting is loaded with dynamic DOM creation and attribute manipulation and I think I've isolated the issue within one set of scripting... below. 该脚本加载了动态DOM创建和属性处理功能,我认为我已经将问题隔离在下面的一组脚本中。

Can any of you geniouses recognize any JS here that may have issues with Chrome and Safari? 你们中的任何一位精灵可以在这里识别出可能与Chrome和Safari有关的任何JS吗? I think I've nailed it down to .style calls (think CSS) that break the presentation. 我认为我已经将其固定为破坏演示的.style调用(认为CSS)。 BTW, it ends up being the SAME EXACT problem when I test with IE9... this may be a clue. 顺便说一句,当我使用IE9进行测试时,最终还是完全相同的问题……这可能是一个线索。

I've searched far and wide on the web and either I'm missing the correct key words to search for or... whatever :) 我已经在网上搜索了很多东西,或者我错过了要搜索的正确关键词,或者……等等:)

    for(var i=0;i<list.length;i++){
    SupportContent.hrefArray[SupportContent.hrefArray.length] = list[i];
    if(i == list.length-1)SupportContent.bookMarkListing();
    ChangeDOM.addChildren({'elType':'div','id':'title~'+list[i]},this.displaySupport);
        var thisTitle = document.getElementById('title~'+list[i]);
        thisTitle.style.paddingTop = '15px';
        thisTitle.onclick = function(){SupportContent.manageLineOpenClose('arrow~'+this.id.split('~',2)[1]+'~c')};
        ChangeDOM.addChildren({'elType':'span','id':'arrowCont~'+list[i]},thisTitle);
            var thisArrow = document.getElementById('arrowCont~'+list[i]);
            thisArrow.style.float = 'left';
            thisArrow.style.width = '30px';
            ChangeDOM.addChildren({'elType':'img','id':'arrow~'+list[i]+'~c','src':'/images/support/arrowClose.jpg','border':'0'},thisArrow);
    ChangeDOM.addChildren({'elType':'div', 'id':'tabs~'+list[i]},this.displaySupport);//tabs container
        var tabContainer = document.getElementById('tabs~'+list[i]);
        tabContainer.style.borderBottom = '5px #35383c solid';
        tabContainer.style.paddingTop = '5px';
        tabContainer.style.backgroundColor = '#151515';
        tabContainer.style.marginTop = '10px';
    ChangeDOM.addChildren({'elType':'div', 'id':'content~'+list[i]},this.displaySupport);//contentContainer
        var contentContainer = document.getElementById('content~'+list[i]);
        contentContainer.style.display = 'none';
        contentContainer.style.overflow = 'hidden';
    for(var j=1;j<5;j++){
        this.buildTab(j,tabNames[j],list[i]);
        this.setContent(j,list[i],contentContainer);
    };

BTW... the ChangeDOM class is a custom class I've created to manipulate the DOM. 顺便说一句... ChangeDOM类是我创建的用于处理DOM的自定义类。 This code is below... 此代码如下...

//custom utility to change the DOM
    //adds children to given node 
    //"keys" format  - {"['elType'] or [element attribute] or     ['text']":"[element type] or [attribute property] or [actual text],"":""...}
function ChangeDOM(){}
ChangeDOM.prototype.addChildren = function(keys,parentNodeObject){
//alert(parentNodeObject.id);
var elName = '';
if (keys["elType"] == 'input'){ 
    if (keys["type"] == 'radio'){
        try{
            elName = document.createElement('<input type="radio" name="fldID" />');  
        }catch(err){  
            elName = document.createElement('input'); 
        }
        try{elName.setAttribute('type','radio');}catch(err){elName.type = 'radio'};
        elName.setAttribute('name','fldID'); 
    }
}
if(elName == '')elName=document.createElement(keys["elType"]);
for(var key in keys){
    if(key != "elType"){
        switch(key){
            case('type'):   if (keys[key] == 'radio')break;
                            elName.type = keys[key];
                            break;
            case('name'):   elName.name = keys[key];
                            break;
            case('value'):  elName.value = keys[key];
                            break;
            case('id'):     elName.id = keys[key];
                            break;
            case('href'):   elName.href = keys[key];
                            break;
            default:        if(key !='text')elName.setAttribute(key,keys[key]);
                            break;
        }
    }
}
parentNodeObject.appendChild(elName);
if(keys['text']){
    if(keys["elType"] == "input"){
        this.addChildren({'text':keys['text']},parentNodeObject);
    }else{
        var txt=document.createTextNode(keys[key]);
        elName.appendChild(txt);
    }
}
return;
}
    //clears all children from given node
ChangeDOM.prototype.clearChildren = function(parentNodeObject){
        if(parentNodeObject.childNodes){
            var nodechildren = new Array();
            nodechildren = parentNodeObject.childNodes;
            if(nodechildren.length>0)for(i=0;nodechildren.length;i++)parentNodeObject.removeChild(parentNodeObject.lastChild);
        }
        return;
    }
    //updates text for a given node
ChangeDOM.prototype.updateText = function(newText,parentNodeObject){
        this.clearChildren(parentNodeObject);
        this.addChildren({'text':newText},parentNodeObject);
    }

I found the solution. 我找到了解决方案。 It was not the tilde or bad .js. 它不是波浪号或糟糕的.js。 It was what I thought... css. 这就是我的想法... CSS。 Once I started specifying the widths of the boxes my scripting was building it all came together. 一旦开始指定框的宽度,我的脚本即已开始构建,所有这些都放在一起了。 Other browsers, it seems, was assuming widths. 似乎其他浏览器都采用宽度。

Thanks everyone for your input. 谢谢各位的意见。

On another note, though I do like JQuery and am using it from time to time, I like the raw power of JS better. 另一方面,尽管我确实喜欢JQuery并不时使用它,但我更喜欢JS的原始功能。 And even with using JQuery, I would have had to still specify widths to get it right. 即使使用JQuery,我也必须指定宽度才能正确使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM