JavaScript - Ie7 - Site Speed Is Dead Slow. What Could Be The Problem?
Hello Experts,
I did a website & I am having trouble wit it. In IE8, FF& Chrome, the site works perfectly. But in IE7, the site slows down very much that even the link hover effect doesn't show properly. I believe its some kind of javascript or Ajax request which is causing such delay. Can you guys please help me sort this out.... Here is the site with functionality... http://tinyurl.com/3qkunvy Here is the site without functionality but just the gallery is integrated... http://tinyurl.com/439ejhk The speed was even better before the Ajax is applied for contents. Any solutions/fixes please... Similar TutorialsHey All, I've got the following site that loads great in FF and Chrome (no surprise), but is terribly slow in IE7. It's even quick in IE6, but not 7. Here's the site: http://www.hanshawengines.com/ Now I'm using JQuery in a couple places, but it's by no means nothing crazy. The page is fairly simple. I thought of preloading the main content images, but even after they are loaded in the cycle, the loading time is still slow. Any suggestions on how I could improve this would be greatly appreciated. Thanks. I have this horizontal news ticker which works just perfect in ie7 regarding to speed, but when looking at the same page in ie8 the speed is very slow... Has anybody else encountered this, and if yes... How do I solve this? Code: initialize: function(element, options) { this.setOptions({ marHeight: 18, marWidth: 565, steps: 20, speed: 20, direction: 'left', pauseOnOver: true, pauseOnContainerOver: true }, options); this.timer = null; this.textElement = null; this.mooqueeElement = element; this.constructMooquee(); } Thanks in advance :-) Hello, I'm working on a rotator and I'm needing to slow it down. I think I would use var speed right? How would I use it in this script? <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.slideshow').cycle({ fx: 'fade' }); }); </script> Hello. I have a problem. I use google map to show some points. I have to show all points for some region, and number of points gets to 4.000. So it takes some minutes to show all points. I use gif image-> size: 400 bytes I found http://fundrace.huffingtonpost.com/ and it takes only couple of seconds to load more 1000 markes. Does someone know how to resolve this? Thanks Hi all, I'm justing wondering about the behavior of JS in regards to adding elements, suppose I have something like this Code: <div id="myDiv"></div> ... function test() { for (i=0 i<100; i++) { var obj = document.create("div"); // do stuff to style div and set content document.getElementById("myDiv").appendChild(obj); } // DO SOMETHING WITH ONE OF THESE DIVS } I'm just wondering at the point I hit that "// DO SOMETHING WITH ONE OF THESE DIVS", are all the divs I have added in the DOM available to access? I ask because I have some code at work in which a tester is reporting an error that happens which I can't reproduce, and they and others have had it a few times. The only way I can explain it in my mind is if the div is not available to me at the time of execution. So I'm just looking to rule it out or confirm my hunch. Is document.getElementById("myDiv").appendChild(obj); synchronous and the next line of code wont execute until the DOM is ready or is it in fact a asynchronous call and therefore adding alot of elements to the DOM could result in a lag so some divs or not available straight away. Any information much appreciated, I hope I have been clear enough. I'm using IE7 and so are the testers. Thanks, Dale I have a piece of raw code. I want to make some images greater/smaller onmouseover/onmouseout, in a graduate mode, on using some independent setTimeout objects which are to be started/clear . It works ok if the mouse goes up and down at a reasonable speed. But if the movement is fast, the onmouseout looks to fail in firing (and some images remain on their bigger stage), which is somehow weird. Where could be the mistake? What did I make wrong (except that I might have had done that with Flash)? Any thoughts? You have in the attachment (see test.zip) the full example, with the used images, as well. Code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <style type="text/css"> img{ width:144px; height:36px; cursor:pointer; } </style> <script type="text/javascript"> var big1,big2,big3,small1,small2,small3, step=1; function bigPic1(obj,w,h){ w+=4;h++; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h<55){big1=setTimeout(function(){bigPic1(obj,w,h)},step)} } function smallPic1(obj,w,h){ w-=4;h--; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h>36){small1=setTimeout(function(){smallPic1(obj,w,h)},step)} } function bigPic2(obj,w,h){ w+=4;h++; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h<55){big2=setTimeout(function(){bigPic2(obj,w,h)},step)} } function smallPic2(obj,w,h){ w-=4;h--; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h>36){small2=setTimeout(function(){smallPic2(obj,w,h)},step)} } function bigPic3(obj,w,h){ w+=4;h++; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h<55){big3=setTimeout(function(){bigPic3(obj,w,h)},step)} } function smallPic3(obj,w,h){ w-=4;h--; obj.style.width=w+'px'; obj.style.height=h+'px'; if(h>36){small3=setTimeout(function(){smallPic3(obj,w,h)},step)} } function setAtt(){ var allImg=document.getElementById('menu').getElementsByTagName('img'), img, i=0; while(img=allImg[i++]){ img.style.width='144px'; img.style.height='36px'; img.ind=i; img.onmouseover=function(){ if('small'+this.ind){clearTimeout('small'+this.ind)}; window['bigPic'+this.ind](this,parseInt(this.style.width),parseInt(this.style.height)) }; img.onmouseout=function(){ if('big'+this.ind){clearTimeout('big'+this.ind)}; window['smallPic'+this.ind](this,parseInt(this.style.width),parseInt(this.style.height)) }; } } onload=setAtt </script> </head> <body> <div id="menu"> <div> <img src="01.png" width="144" height="36" border="0" alt=""> </div> <br> <br> <div> <img src="02.png" width="144" height="36" border="0" alt=""> </div> <br> <br> <div> <img src="03.png" width="144" height="36" border="0" alt=""> </div> </div> </body> </html> In the home page (index.html) i have a flash intro. The first time a user sees the website, the intro should play. Once he goes to another page (about_us or contact_us) and comes back to the home page, it should show a different swf (the version without the intro) - i have created two swf files. I need to know how to change them when the user has already seen the intro or was in the home page before. When i googled, i found something on cookies. I have no clue on how to set them and change the swf file. Would be great if someone has already done this or point me to a tutorial. i need java script. please help!!!!!!! i have pasted below java script code. please check write or wrong <script language = "JavaScript" type="text/javascript"> // Remove down to "ConnectionSpeed Detection section" if you don't want to use cookies // If you drop a cookie it can be picked up on return by php or something else function setCookie(name, value, expire) { document.cookie = name + "=" + escape(value) + ((expire == null ? "" : (";expires=" + expire.toGMTString()))); // alert('A cookie called '+name+' is now set with value: '+value); //enable to alert user of cookie } function getExpireDate() { var expires = new Date(); expires.setTime((new Date().getTime() + 1000 * 60 * 60 * 24 * 365)); return expires; } // ConnectionSpeed Detection section var datasize = 31468; // Size of data being transferred, in Bytes var startTime = 0; var endTime = 0; var date = 0; var ctype = ""; var textMessage = ""; function calcThroughput() { var diffTimeMilliseconds = endTime - startTime; var diffTimeSeconds = diffTimeMilliseconds / 1000; var bits = (datasize * 8); // convert Bytes to bits, var kbits = bits / 1024; // convert bits to kbits var throughput1 = kbits / (diffTimeSeconds * 100 / 100); throughput = throughput1 * .93; // account for IP packet header overhead - averages about 7% setCookie("MediaThroughput", throughput, getExpireDate()); // Remove to not use cookie if (throughput < 185) { ctype = "Home.aspx"; } if (throughput > 185) { ctype = "intro.aspx"; } textMessage = "Bandwidth: <B>" + ctype + "</B><br>time to load: (sec): <B>" + diffTimeSeconds + "</B><BR>kbits loaded:<B> " + kbits + "</B><BR>Throughput (kbps): <B>" + throughput + "</B>" document.location = ctype; } </script> <script language = "Javascript" type="text/javascript"> <!-- A bunch of binary data here in the actual file --> </script> </head><body> <script language = "Javascript" type="text/javascript"> date = new Date(); endTime = date.getTime(); calcThroughput(); </script> automatic detect default page and check to low band version go to html page or high band version go to flash page. please help!!!!!!!!!!!!!!!!!!!!!!!!! i need script will detect connection speed and redirect to a page:
I have made myself an HTML Menu which is located on top of my current Flash object. I have a question whether it really is not possible to get the same effect as 'text' has on the original "Flash Menu" EX: www.moebelarkitekten.dk and get the same effect over at my new HTML menu (Coded with Jquery) EX: http://www.richyjassal.co.uk/moebelar/ Right now it is almost the same effect, but only: OnMouseOver align text to Right OnMouseOut text to align left A guide, or other? was wondering if it made sense to optimize the comparison order inside an if() statement if one of the comparison targets is a function call eg: Code: var a = true, b = function() {return false;}; if (b() || a) {...} if (a || b()) {...} would the second statement run faster because it would theoretically never need to call b() in this situation? can the eval order be relied on? does this depend on the js engine/internal optimizations? thanks, Leon Hello good coders! Thanks to the wonderful script provided by coothead he http://www.codingforums.com/showthread.php?t=87036 I was wondering how I could adjust the transition/fade speed between the images in the script? I tried a couple of different ways, but I couldn't get it working. Does anyone know how I can adjust this in a cross-browser compatible way? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>multiple image maps</title> <base href="http://coothead.homestead.com/files/"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> /*<![CDATA[*/ #mapImage_holder { text-align:center; } #mapImage { border:1px solid #000; } /*//]]>*/ </style> <script type="text/javascript"> //<![CDATA[ var maps=new Array(); maps[0]='dots.gif,#dots'; maps[1]='map.jpg,#blood'; maps[2]='apple0.jpg,#apples'; var c=0; var speed=1000*10; //set for 10 secs, change to suit needs. function swapMap() { obj=document.getElementById('mapImage'); if(c==maps.length) { c=0; } obj.src=maps[c].split(',')[0]; obj.useMap=maps[c].split(',')[1]; c++; setTimeout('swapMap()',speed); } window.onload=swapMap; //]]> </script> </head> <body> <div id="mapImage_holder"> <img id="mapImage" src="dots.gif" alt="" usemap="#dots"/> </div> <div> <map id="dots" name="dots"> <area coords="85,40,110,65" href="http://www.bbc.co.uk" alt="" /> <area coords="225,100,250,125" href="http://www.itv.com/" alt=""/> <area coords="345,140,370,165" href="http://www.channel4.com/" alt=""/> <area coords="405,270,430,295" href="http://www.guardian.co.uk/" alt=""/> <area coords="35,290,60,315" href="http://www.independent.co.uk/" alt=""/> <area coords="605,460,630,485" href="http://www.thesun.co.uk/" alt=""/> </map> <map id="blood" name="blood"> <area coords="40,144,80,171" href="http://www.codingforums.com/" alt="" /> <area coords="112,144,152,171" href="http://www.w3schools.com/" alt="" /> <area coords="184,144,224,171" href="http://w3c.org/" alt="" /> <area coords="256,144,296,171" href="http://www.alistapart.com/" alt=""/> </map> <map id="apples" name="apples"> <area coords="0,0,116,146" href="http://www.axialis.com/" alt=""/> <area coords="124,0,236,146" href="http://www.photoshopsupport.com/" alt=""/> <area coords="244,0,360,146" href="http://www.photoshopuser.com/" alt=""/> <area coords="0,154,116,280" href="http://www.planetphotoshop.com/" alt=""/> <area coords="124,154,236,280" href="http://www.photoshopcafe.com/" alt=""/> <area coords="244,154,360,280" href="http://www.mozilla.com/" alt=""/> </map> </div> </body> </html> hi at the first Sorry for my bad english. I have a joomla at the wrap5.5 framework I knew my frame work for Regulation module position height have a js function. this function is ok in IE5 & ff but in IE9 show very tall my module height. but i dont know what is wrong on this function . i dont know anything about JS. this function : Code: (function(e) { e.fn.matchHeight = function(f) { var a = 0; this.each(function() { a = Math.max(a, e(this).outerHeight()) }); f && (a = Math.max(a, f)); return this.each(function() { var c = e(this), b = c.outerHeight() - c.height(); c.css("min-height", a - b + "px") }) } my website:http://www.joomi.ir Heya guys. My gallery javascript is running very laggy in IE8. Here's an example: www.amex-trading.dk/pizzaovne.php It works fine in chrome, but it's slow when using IE. Any suggestions? I'm trying to slow this image rotator down. I thought I would just change the setInterval part. But it's not working. Quote: $(function() { setInterval( "nextPage()", 7000 ); }); Below is the full script. Am I missing something? Code: // Global variable that controls billboard image rotation var $rotate = 1; // Load this script when page loads $(document).ready(function(){ // Set up a listener so that when anything with a class of 'bbtab' // is clicked, this function is run. $('.bbtab').click(function () { // Turn off autorotation. $rotate = 0; // Remove the 'bboard_page_active' class from the visible tab contents. $('#bboard > ul > li.bboard_page_active').removeClass('bboard_page_active'); // Add the 'bboard_page_active' class to the associated tab contents. $(this.rel).addClass('bboard_page_active'); return false; //stop the links default action }); }); function nextPage() { // id is expected to look like 'bbpage1'. // We just need the number part at the end so that we can figure out which page is next in the rotation. var $active_page = $('#bboard > ul > li.bboard_page_active').attr('id') || 'bbpage0'; var $next_page = parseInt($active_page.substring(6)) + 1; if ($next_page > $('#bboard > ul > li').length) { $next_page = 1; } if ($rotate == 1) { // Remove the 'bboard_page_active' class from the active page. $('#'+$active_page).removeClass('bboard_page_active'); // Add the 'bboard_page_active' class to the next page. $('#bbpage'+$next_page).addClass('bboard_page_active'); // alert("Active page is " + $active_page + " of " + $total_pages + " and next is " + $next_page); } } $(function() { setInterval( "nextPage()", 7000 ); }); hi guys I am looking at this template: http://www.csstemplatesfree.org/prev...ero/index.html I think the sliding at the top happens way too frequently. How can I slow it down? I think it would be better if the slides change once every 6 seconds. Hi, I am writing a basic app for a client where the customer puts in their order ID and phone number and press submit. When testing it on my PC it worked flawlessly. When I tested on a desktop PC where the screen was a touch screen as well as on Android devices, it seems the browser is a bit slow to respond. If you press each number slowly (waiting 0.5 second per press) it works fine. However if use it normal to fast then the browser does not catch every button press. Any and all advice is appreciated to heklp make this work. Code: <title>DLUX Order alert system</title> <head> <center><font color="blue"><b>DLUX Order alert system</b></font></center></br></br> <body onload="empty_to_do();"> <script type="text/javascript"> function addOrderID(key){ var order_id = document.forms[0].order_id; order_id.value = order_id.value + key; } function setToDo(key){ var to_do = document.forms[0].to_do; to_do.value = key; setTimeout(submitForm,100); } function addPhoneNumber(key){ var phone_number = document.forms[0].phone_number; var phone_number_real = document.forms[0].phone_number_real; phone_number.value = phone_number.value + key; phone_number_real.value = phone_number_real.value + key; phone_number_real.value = phone_number_real.value.substr(0,10); if(phone_number_real.value.length <1){ phone_number.value = ''; } if(phone_number_real.value.length >0 && phone_number_real.value.length < 3){ phone_number.value = '(' + phone_number_real.value.substr(0,3) ; } if(phone_number_real.value.length >2 && phone_number_real.value.length < 6){ phone_number.value = '(' + phone_number_real.value.substr(0,3) + ') ' + phone_number_real.value.substr(3,3); } if(phone_number_real.value.length > 5){ phone_number.value = '(' + phone_number_real.value.substr(0,3) + ') ' + phone_number_real.value.substr(3,3) + '-' + phone_number_real.value.substr(6,4); } } function delOrderID(key){ var order_id = document.forms[0].order_id; order_id.value = order_id.value.substring(0, order_id.value.length - 1); } function delPhoneNumber(key){ var phone_number = document.forms[0].phone_number; var phone_number_real = document.forms[0].phone_number_real; phone_number_real.value = phone_number_real.value.substring(0, phone_number_real.value.length - 1); if(phone_number_real.value.length <1){ phone_number.value = ''; } if(phone_number_real.value.length >0 && phone_number_real.value.length < 3){ phone_number.value = '(' + phone_number_real.value.substr(0,3) ; } if(phone_number_real.value.length >2 && phone_number_real.value.length < 6){ phone_number.value = '(' + phone_number_real.value.substr(0,3) + ') ' + phone_number_real.value.substr(3,3); } if(phone_number_real.value.length > 5){ phone_number.value = '(' + phone_number_real.value.substr(0,3) + ') ' + phone_number_real.value.substr(3,3) + '-' + phone_number_real.value.substr(6,4); } } function resetOrderID(key){ var order_id = document.forms[0].order_id; order_id.value = ''; } function resetPhoneNumber(key){ var phone_number = document.forms[0].phone_number; var phone_number_real = document.forms[0].phone_number_real; phone_number.value = ''; phone_number_real.value = ''; } function submitForm(){ document.forms[0].submit(); } function emptyCode(){ document.forms[0].order_id.value = ""; document.forms[0].to_do.value = ""; document.forms[0].phone_number.value = ""; document.forms[0].phone_number_real.value = ""; } function empty_to_do(){ document.forms[0].to_do.value = ""; } function empty_order_id(){ document.forms[0].order_id.value = ""; } function empty_phone_number(){ document.forms[0].phone_number.value = ""; document.forms[0].phone_number_real.value = ""; } </script> <style> body { text-align:center; background-color:#D3D3D3; font-family:Verdana, Arial, Helvetica, sans-serif; } #keypad {margin:auto; margin-top:20px;} #keypad tr td { vertical-align:middle; text-align:center; border:1px solid #000000; font-size:18px; font-weight:bold; width:180px; height:160px; cursor:pointer; background-color:#666666; color:#CCCCCC } #keypad tr td:hover {background-color:#999999; color:#FFFF00;} .display { width:130px; margin:10px auto auto auto; background-color:#000000; color:#00FF00; font-size:18px; border:1px solid #999999; } #message { text-align:center; color:#009900; font-size:14px; font-weight:bold; display:none; } #submit { width: 10em; height: 5em; } </style> <form action="" method="post"> <font color="red"><b>Order ID: </b></font> <input type="text" name="order_id" value="9" maxlength="10" class="display"/> <table id="DOVID_keypad" cellpadding="15" cellspacing="5"> <tr> <td><input type="button" style="width:75;height:75" value="1" onclick="addOrderID('1');"></td> <td><input type="button" style="width:75;height:75" value="2" onclick="addOrderID('2');"></td> <td><input type="button" style="width:75;height:75" value="3" onclick="addOrderID('3');"></td> </tr> <tr> <td><input type="button" style="width:75;height:75" value="4" onclick="addOrderID('4');"></td> <td><input type="button" style="width:75;height:75" value="5" onclick="addOrderID('5');"></td> <td><input type="button" style="width:75;height:75" value="6" onclick="addOrderID('6');"></td> </tr> <tr> <td><input type="button" style="width:75;height:75" value="7" onclick="addOrderID('7');"></td> <td><input type="button" style="width:75;height:75" value="8" onclick="addOrderID('8');"></td> <td><input type="button" style="width:75;height:75" value="9" onclick="addOrderID('9');"></td> </tr> <tr> <td><input type="button" style="width:75;height:75" value="RESET" onclick="resetOrderID('');"></td> <td><input type="button" style="width:75;height:75" value="0" onclick="addOrderID('0');"></td> <td><input type="button" style="width:75;height:75" value="BACK" onclick="delOrderID('');"></td> </tr> </table> <br/> <font color="red"><b>Phone Number: </b></font> <input type="text" name="phone_number" value="" maxlength="15" class="display"/><input type="hidden" name="phone_number_real" value="" maxlength="10" class="display"/></tr> <table id="keypad" cellpadding="5" cellspacing="3"> <tr> <td onclick="addPhoneNumber('1');">1</td> <td onclick="addPhoneNumber('2');">2</td> <td onclick="addPhoneNumber('3');">3</td> </tr> <tr> <td onclick="addPhoneNumber('4');">4</td> <td onclick="addPhoneNumber('5');">5</td> <td onclick="addPhoneNumber('6');">6</td> </tr> <tr> <td onclick="addPhoneNumber('7');">7</td> <td onclick="addPhoneNumber('8');">8</td> <td onclick="addPhoneNumber('9');">9</td> </tr> <tr> <td onclick="resetPhoneNumber('');">RESET</td> <td onclick="addPhoneNumber('0');">0</td> <td onclick="delPhoneNumber('');">Back</br>Space</td> </tr> </table> <br> <table id="keypad" cellpadding="10" cellspacing="3"> <td onclick="setToDo('submit');">Submit</td> </table> <input type="hidden" name="to_do" value="" maxlength="100" readonly="readonly" /></tr> </form> </html> Hello guys, The title says it all, my javascript hover menu is running perfect in chrome, but really slow in IE. Take a look here - the menu is called "Produkter" Thanks in regard Hi. I'm using a tooltip javascript from this website: http://sixrevisions.com/tutorials/ja...cript_tooltip/ This is what it looks like when it's working smoothly: http://sandbox.leigeber.com/tooltip/ To fix scrolling issues, I changed (near the lower bottom, under "pos:function(e)"): var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY; to: var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX; I'm using these tooltips for an image map that has 1,000 defined areas. In Firefox, everything works very smoothly. Everything works well and looks smooth/visually pleasing. But in IE, the tooltips are "choppy" and "staticy". They work well when I continuously move my mouse over the image map without stopping. But when I completely stop the cursor on a part of the image map for about 1 full second, and then move my mouse, the tooltip stays where it is even though the mouse has moved. It then takes between 1 - 2 seconds for the tooltip to "catch up" and move to be next to the mouse/cursor - where it is supposed to be. Also, I must note that when I only have a few (like 3 or 4) defined areas for the image map, the tooltip works perfectly fine and smoothly in IE. I'm very new to html and javascript, and so I'm finding myself at a bit of a loss as to why this is occuring. Can anyone offer any help as to how I can make this tooltip go smoothly between defined areas (not sure if that's the correct terminology) of the image map? I'm new to javascript, and so, unsure of which parts could be causing the problems. However, I think it might have to do with the part from pos:function(e) on. If needs be, I'd be happy to post the full javascript code. Code: pos:function(e){ var u = ie ? event.clientY + document.getElementById('bodyid').scrollTop : e.pageY; var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX; tt.style.top = (u - h) + 'px'; tt.style.left = (l + left) + 'px'; } Hi. I am using a mouseover dropdown menu within a rather large table. The script is only 1.6kb so I don't understand why it is going so slow. Mind you this effect is instant in Firefox, Chrome, Safari, Opera. However, in IE 7 it takes about 3-4 seconds. Any advice on how to get this time down in IE 7? Here is a quick sample of the code.
Code: var DDSPEED = 10; var DDTIMER = 15; // main function to handle the mouse events // function ddMenu(id,d){ var h = document.getElementById(id + '-ddheader'); var c = document.getElementById(id + '-ddcontent'); clearInterval(c.timer); if(d == 1){ clearTimeout(h.timer); if(c.maxh && c.maxh <= c.offsetHeight){return} else if(!c.maxh){ c.style.display = 'block'; c.style.height = 'auto'; c.maxh = c.offsetHeight; c.style.height = '0px'; } c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER); }else{ h.timer = setTimeout(function(){ddCollapse(c)},50); } } // collapse the menu // function ddCollapse(c){ c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER); } // cancel the collapse if a user rolls over the dropdown // function cancelHide(id){ var h = document.getElementById(id + '-ddheader'); var c = document.getElementById(id + '-ddcontent'); clearTimeout(h.timer); clearInterval(c.timer); if(c.offsetHeight < c.maxh){ c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER); } } // incrementally expand/contract the dropdown and change the opacity // function ddSlide(c,d){ var currh = c.offsetHeight; var dist; if(d == 1){ dist = (Math.round((c.maxh - currh) / DDSPEED)); }else{ dist = (Math.round(currh / DDSPEED)); } if(dist <= 1 && d == 1){ dist = 1; } c.style.height = currh + (dist * d) + 'px'; c.style.opacity = currh / c.maxh; c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')'; if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){ clearInterval(c.timer); } } further reference: http://problemcorrected.com |