Will pay $$ for help to fix javascript.

Discussion in 'JavaScript' started by zebra, Jun 24, 2008.

  1. #1
    This javascript code works in FF, but breaks in IE. Please help me to fix it.

    
    var ns4 = document.layers;
    var ns6 = document.getElementById && !document.all || (navigator.userAgent.indexOf('Opera') >= 0);
    var ie4 = document.all;
    
    var requester = null;
    
    var offsetX = 0;
    var offsetY = 20;
    var toolTipSTYLE="";
    var CAPTION='cap';
    var FG='fg';
    var BG='bg';
    var TEXTCOLOR='tc';
    var CAPTIONCOLOR='cc';
    var WIDTH='tw';
    var HEIGHT='th';
    var FONT='font';
    var POSITIONY='posy';
    var hideToolTip=true;
    var cap, fg, bg, tc, cc, tw, th, font, posy = 0;
    
    function initToolTips() {
        if(ns4||ns6||ie4) {
            if(ns4) toolTipSTYLE = document.toolTipLayer;
            else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
            else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
            if(ns4);
            else {
                toolTipSTYLE.visibility = "visible";
                toolTipSTYLE.display = "none";
            }
        }
    }
    
    function showLoadedData() {
        var msg = 'ERROR';
        if (requester.readyState == 4) { 
            if (requester.status == 200) {
                msg = requester.responseText;
            } else { 
                msg = "ERROR loading details";
            }
        } 
        document.getElementById('infoDivTextRow').innerHTML = msg;
        return true;
    }
    
    function toolTipHide() {
        if(ns4) {
            toolTipSTYLE.visibility = "hidden";
        } else {
            toolTipSTYLE.display = "none";
            var IfrRef = document.getElementById('DivShim');
            IfrRef.style.display = "none";
        }
    }
    
    function toolTip() {
        
        if(arguments.length < 1) { // hide
            if (hideToolTip == false) {
                return;
            }
            if(ns4) {
                toolTipSTYLE.visibility = "hidden";
            } else {
                toolTipSTYLE.display = "none";
                var IfrRef = document.getElementById('DivShim');
                IfrRef.style.display = "none";
            }
        } else { // show
            e = arguments[0];
            var msg = arguments[1];
            
            var type = arguments[2];
            fg = "#000000";
            bg = "#DDDDDD";
            tc = "#000000";
            cc= "#FFFFFF";
            font = "Verdana,Arial,Helvetica";
            tw = '';
            th = '';
            cap = '';
            posy = 0;
            for(var i = 3; i < arguments.length; i+=2) {
                switch (arguments[i]) {
                    case "cap": cap = arguments[i+1]; break;
                    case "font": font = arguments[i+1]; break;
                    case "fg": fg = arguments[i+1]; break;
                    case "bg": bg = arguments[i+1]; break;
                    case "tc": tc = arguments[i+1]; break;
                    case "cc": cc = arguments[i+1]; break;
                    case "tw": tw = arguments[i+1]; break;
                    case "th": th = arguments[i+1]; break;
                    case "posy": posy = arguments[i+1]; break;
                }
            }
            var imgdir = 'images/';
            var content = '';
            titletext = 'Details';
    
            content = '<div style="width: ' + tw + 'px;">' + msg + '</div>';
            
            if(ns4) {
                toolTipSTYLE.document.write(content);
                toolTipSTYLE.document.close();
                toolTipSTYLE.visibility = "visible";
            } else if(ns6) {
                moveToMouseLoc(e);
                document.getElementById("toolTipLayer").innerHTML = content;
                toolTipSTYLE.display='block';
            } else if(ie4) {
                moveToMouseLoc();
                
                document.all("toolTipLayer").innerHTML=content;
                toolTipSTYLE.display='block';
                var IfrRef = document.getElementById('DivShim');
                var DivRef = document.getElementById('toolTipLayer');
                IfrRef.style.width = DivRef.offsetWidth;
                IfrRef.style.height = DivRef.offsetHeight;
                IfrRef.style.top = DivRef.style.top;
                IfrRef.style.left = DivRef.style.left;
                IfrRef.style.zIndex = DivRef.style.zIndex - 1;
                IfrRef.style.display = "block";
            }
        }
    }
    
    function moveToMouseLoc(e, tw, th) {
        if(ns4||ns6) {
            x = e.pageX;
            y = e.pageY;
        } else {
            x = event.x + 200;
            y = event.y + 120;
        }
        
        var left = x + 12;
        var top = y - 20;
        
        if(ns4||ns6) {
            toolTipSTYLE.left = left + "px";
            toolTipSTYLE.top  = top + "px";
        } else {
            toolTipSTYLE.left = left;
            toolTipSTYLE.top  = top;    
        }
         
        return true;
    }
    
    
    Code (markup):

     
    zebra, Jun 24, 2008 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    please link to the page it is on so i can check for errors
     
    crath, Jun 26, 2008 IP
  3. =Messa=

    =Messa= Peon

    Messages:
    104
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Has this been taken care of yet?

    If not, let me see the page/website where the code is being used.
     
    =Messa=, Jul 1, 2008 IP