designer76 Posted August 14, 2009 Share Posted August 14, 2009 Can someone help me figure out why these two scripts conflict in Firefox and Safari? They work fine in Internet Explorer, and they work fine in ALL browsers when they don't have to work together on the same page. When they both need to work on the same page, it's the div/column resize script that is acting up in Safari and Firefox (again, it works fine in IE). What's really strange is that when I click on my firebug icon (in the lower righthand corner) in Firefox the divs/columns resize like they should and everything looks fine. It's almost as if it's not resizing in real time like it should be, and something about me clicking that icon is making it refresh or update or something. Any help given with this matter would be greatly appreciated! Resize two Divs (columns) to be the same height: // Replace 'center' 'right' and 'left' with the ID names of the columns you want to balance. // The last one is there to show how you can add more columns. Just delete the ones you're not using. var divs = new Array('col1, 'col2'); // Initialize Scripts - is this a browser that understands DOM? function scriptInit() { if (!document.getElementById) { return; } } // Set up Event Listener function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; } } // Start Column Script function setTall() { if (document.getElementById) { var maxHeight = 0; for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { var div = document.getElementById(divs[i]); div.style.height = null; if (div.offsetHeight > maxHeight) maxHeight = div.offsetHeight; } } for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { var div = document.getElementById(divs[i]); div.style.height = maxHeight + 'px'; if (div.offsetHeight > maxHeight) { div.style.height = (maxHeight - (div.offsetHeight - maxHeight)) + 'px'; } } } } } // Assign one of the columns to the TextResizeDetector. function initTall() { if (document.getElementById) { for (var i = 0; i < divs.length; i++) { if (document.getElementById(divs[i]) != null) { TextResizeDetector.TARGET_ELEMENT_ID = divs[i]; break; } } setTall(); } } // Fire Events addEvent(window, 'load', initTall, false); addEvent(window, 'resize', setTall, false); /* Detects changes to font sizes when user changes browser settings Fires a custom event with the following data: iBase : base font size iDelta : difference in pixels from previous setting iSize : size in pixel of text author Lawrence Carvalho carvalho@uk.yahoo-inc.com */ // @constructor TextResizeDetector = function() { var el = null; var iIntervalDelay = 200; var iInterval = null; var iCurrSize = -1; var iBase = -1; var aListeners = []; var createControlElement = function() { el = document.createElement('span'); el.id='textResizeControl'; el.innerHTML=' '; el.style.position="absolute"; el.style.left="-9999px"; var elC = document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID); // insert before firstChild if (elC) elC.insertBefore(el,elC.firstChild); iBase = iCurrSize = TextResizeDetector.getSize(); }; function _stopDetector() { window.clearInterval(iInterval); iInterval=null; }; function _startDetector() { if (!iInterval) { iInterval = window.setInterval('TextResizeDetector.detect()',iIntervalDelay); } }; function _detect() { var iNewSize = TextResizeDetector.getSize(); if(iNewSize!== iCurrSize) { for (var i=0;i <aListeners.length;i++) { aListnr = aListeners[i]; var oArgs = { iBase: iBase,iDelta:((iCurrSize!=-1) ? iNewSize - iCurrSize + 'px' : "0px"),iSize:iCurrSize = iNewSize}; if (!aListnr.obj) { aListnr.fn('textSizeChanged',[oArgs]); } else { aListnr.fn.apply(aListnr.obj,['textSizeChanged',[oArgs]]); } } } return iCurrSize; }; var onAvailable = function() { if (!TextResizeDetector.onAvailableCount_i ) { TextResizeDetector.onAvailableCount_i =0; } if (document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)) { TextResizeDetector.init(); if (TextResizeDetector.USER_INIT_FUNC){ TextResizeDetector.USER_INIT_FUNC(); } TextResizeDetector.onAvailableCount_i = null; } else { if (TextResizeDetector.onAvailableCount_i<600) { TextResizeDetector.onAvailableCount_i++; setTimeout(onAvailable,200) } } }; setTimeout(onAvailable,500); return { /* * Initializes the detector * * @param {String} sId The id of the element in which to create the control element */ init: function() { createControlElement(); _startDetector(); }, /** * Adds listeners to the ontextsizechange event. * Returns the base font size * */ addEventListener:function(fn,obj,bScope) { aListeners[aListeners.length] = { fn: fn, obj: obj } return iBase; }, /** * performs the detection and fires textSizeChanged event * @return the current font size * @type {integer} */ detect:function() { return _detect(); }, /** * Returns the height of the control element * * @return the current height of control element * @type {integer} */ getSize:function() { var iSize; return el.offsetHeight; }, /** * Stops the detector */ stopDetector:function() { return _stopDetector(); }, /* * Starts the detector */ startDetector:function() { return _startDetector(); } } }(); /*** end TextResizeDetector */ TextResizeDetector.TARGET_ELEMENT_ID = 'doc'; TextResizeDetector.USER_INIT_FUNC = function() { var iBase = TextResizeDetector.addEventListener(setTall, null); }; Click link to show hidden text: function expand(ele) { if (document.getElementById('answer'+ele).style.display == '') document.getElementById('answer'+ele).style.display='none'; else document.getElementById('answer'+ele).style.display=''; for (i=0;i <= 75;i++) { if (document.getElementById('answer'+i) != null && i != ele) document.getElementById('answer'+i).style.display='none'; } } function collapse(ele) { document.getElementById('answer'+ele).style.display='none'; } Quote Link to comment Share on other sites More sharing options...
designer76 Posted August 15, 2009 Author Share Posted August 15, 2009 Can anyone offer me any help with this? Quote Link to comment Share on other sites More sharing options...
designer76 Posted August 17, 2009 Author Share Posted August 17, 2009 Please, is there anyone willing to help me? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.