JavaScript - Navigation Bar Works Once Then Stops Working
I'm trying to create a navigation bar with four elements. If the element is currently selected it will have a "red" background image, if it is one of the other 3, it will have a "black" background image. my four tabs are 'timetable, homework, notifications and sport' I tried making 8 functions like the 2 below
Code: function setTimeRed() { document.getElementById("time").style.ClassName = 'timetable_r'; } function setTimeBlack() { document.getElementById("time").style.ClassName = 'time_r'; } And then four blocks like this: Code: function changeTimeButton() { var timePath = new String(); timePath = document.getElementById("timetable").style.backgroundImage; if(timePath == "url(assets/img/tabs/time_black.png)" || timePath == "") { setTimeRed(); setHomeBlack(); setNotiBlack(); setSportBlack(); } else { } } finally, my html has this: Code: <div id="tabbar"> <ul id="tabs"> <a href"#" onclick="changeTimeButton()"> <li id="timetable" class="time_b"> <p>Timetable</p> </li> </a> <a href"#" onclick="changeHomeButton()"> <li id="homework" class="home_b"> <p>Homework</p> </li> </a> <a href"#" onclick="changeNotiButton()"> <li id="notifications" class="noti_b"> <p>Notifications</p> </li> </a> <a href"#" onclick="changeSportButton()"> <li id="sport" class="sport_b"> <p>Sport</p> </li> </a> </ul> </div> It works once then does nothing. Why, and how would I go about fixing this?? Please help! Similar TutorialsHey guys, so I'm trying to make a single function that will check to make sure the e-mails in both fields match AND to make sure the e-mail is in proper format. Strangely, with both if statements included the form will return no messages at all. If I comment out the if statement checking for proper format, the if statement to check for matching e-mail works just fine. I want this all to be in one function because I'm wanting it to be executed onSubmit with the form. Let me know what you guys think, any help is greatly appreciated: Code: <html> <head> <script type="text/javascript"> function verifyEmail() { var x = document.forms["emailForm"]["enterEmail"].value; var y = document.forms["emailForm"]["confirmation"].value; var atpos = x.indexOf("@"); var dotpos = x.lastIndexOf("."); if (x != y) { var msg = "The email addresses entered do not match, please enter matching email addresses"; document.getElementById("error").innerHTML = msg; return false; } if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 > = x.length) { var msg = "Improper e-mail format"; document.getElementById("error").innerHTML = msg; return false; } else { return; } } </script> </head> <body> <form name="emailForm" onsubmit="return verifyEmail();" method="post"> E-Mail Address: <input type="text" name="enterEmail"> Confirm E-Mail Address: <input type="text" name="confirmation"> <input type="submit" value="Submit"> <span id="error"></span> </form> </body> </html> I have a simple function to display an image when called, but if I try to rewrite the function to take the image as an argument, it stops working. I've looked at other function examples on the web but can't figure out what I am missing. Can anyone help? works: Code: <html> <script language="JavaScript"> var ImagePlusSign = '<img src="plus.jpg" name="slide" width="65" height="50"/>'; function FlashImagesThenWait() { document.getElementById("first").innerHTML = ImagePlusSign } setTimeout(FlashImagesThenWait, 1500); </script> <body>Hello. <div id="first"> </div> </body> </html> does NOT work : Code: <html> <script language="JavaScript"> var ImagePlusSign = '<img src="plus.jpg" name="slide" width="65" height="50"/>'; function FlashImagesThenWait(z) { document.getElementById("first").innerHTML = z } setTimeout(FlashImagesThenWait(ImagePlusSign), 1500); </script> <body>Hello. <div id="first"> </div> </body> </html> My website is all up and running and I decided to put a new image viewing script on, I already had a revolving image script showing all my previous work before but the latest script has totally stopped the previous from working. You can view what I mean at www.actioncomputing.co.uk I am using 2 scripts both available on Dynamic Drive they are Lightbox image viewer 2.03a Ultimate Fade-in slideshow (v2.1) If anyone can tell me why this is I would be extremely gratefull. I have a clock that works onbodyload, however using the below function on the same page, stops my clock even coming up, any help would be great. Code: <script language="JavaScript"> var HAS_EXPIRED = 'Time has Expired!'; var IS_NONE = 'None'; function secondCountdown(s){ if(s){ var timeleft = document.getElementById('timeleft').innerHTML; if((timeleft == HAS_EXPIRED) || (timeleft == IS_NONE)) return false; timeleft = timeleft.replace('<font>', ''); timeleft = timeleft.replace('</font>', ''); var time = timeleft.split(":"); var secs = time[2] * 1; var mins = time[1] * 1; var hrs = time[0] * 1; secs += (mins * 60) + (hrs * 3600); secs -= 1; if(secs <= 0){ document.getElementById('timeleft').innerHTML = HAS_EXPIRED; return false; } else { hrs = Math.floor(secs/3600); secs -= (hrs * 3600); mins = Math.floor(secs/60); secs -= (mins * 60); if(hrs < 10) hrs = '0' + hrs; if(mins < 10) mins = '0' + mins; if(secs < 10) secs = '0' + secs; document.getElementById('timeleft').innerHTML = hrs + ':' + mins + ':' + secs; } } setTimeout('secondCountdown(true)',1000); } bootloaderAdd('secondCountdown()'); bootloaderOn(); </script> Hey everyone, I have a page where I call two external javascript files, and they work perfectly when I have all the files on my desktop. But once I transferred all the files into a folder, the scripts stop working. What's going on?! EDIT: Nevermind. I just forgot to relocate my jquery file! ok so Code: document.write("Goodbye!"); works but I put ^ that inside a function Code: function SayHello () ( document.write("Goodbye!"); ) and it stops working? I know the function call works because when I place some code to display an image in SayHello function, it displays the image. Hello experts, I have inserted the easy slider code into my web page to make a sliding gallery. I attempted to modify the code so that numeric navigation AND arrow navigation (next, previous) could toggle slides BUT I can't see the number navigation in IE6. Every other browser I have tested (mac Safari, Firefox, and Google Chrome as well as IE7,8) work perfectly. Since I modified the original, I assume the error is in my javascript code OR in my CSS. Please help. I wouldn't ask if I wasn't at the end of my rope! Here is the Javascript: Code: /* * Easy Slider 1.7 - jQuery plugin * written by Alen Grakalic * http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding * * Copyright (c) 2009 Alen Grakalic (http://cssglobe.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Built for jQuery library * http://jquery.com * */ (function($) { $.fn.easySlider = function(options){ // default configuration properties var defaults = { prevId: 'prevBtn', prevText: 'Previous', nextId: 'nextBtn', nextText: 'Next', controlsShow: true, controlsBefo '', controlsAfter: '', controlsFade: true, firstId: 'firstBtn', firstText: 'First', firstShow: false, lastId: 'lastBtn', lastText: 'Last', lastShow: false, vertical: false, speed: 900, auto: false, pause: 3000, continuous: false, numeric: false, numericId: 'controls' }; var options = $.extend(defaults, options); this.each(function() { var obj = $(this); var s = $("li", obj).length; var w = $("li", obj).width(); var h = $("li", obj).height(); var clickable = true; obj.width(w); obj.height(h); obj.css("overflow","hidden"); var ts = s-1; var t = 0; $("ul", obj).css('width',s*w); if(options.continuous){ $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); $("ul", obj).css('width',(s+1)*w); }; if(!options.vertical) $("li", obj).css('float','left'); if(options.controlsShow){ var html = options.controlsBefore; if(options.numeric){ html += '<ol id="'+ options.numericId +'"></ol>' if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>'; }; html += options.controlsAfter; $(obj).after(html); }; for(var i=0;i<s;i++){ $(document.createElement("li")) .attr('id',options.numericId + (i+1)) .html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>') .appendTo($("#"+ options.numericId)) .click(function(){ animate($("a",$(this)).attr('rel'),true); }); $("a","#"+options.nextId).click(function(){ animate("next",true); }); $("a","#"+options.prevId).click(function(){ animate("prev",true); }); $("a","#"+options.firstId).click(function(){ animate("first",true); }); $("a","#"+options.lastId).click(function(){ animate("last",true); }); }; function setCurrent(i){ i = parseInt(i)+1; $("li", "#" + options.numericId).removeClass("current"); $("li#" + options.numericId + i).addClass("current"); }; function adjust(){ if(t>ts) t=0; if(t<0) t=ts; if(!options.vertical) { $("ul",obj).css("margin-left",(t*w*-1)); } else { $("ul",obj).css("margin-left",(t*h*-1)); } clickable = true; if(options.numeric) setCurrent(t); }; function animate(dir,clicked){ if (clickable){ clickable = false; var ot = t; switch(dir){ case "next": t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; break; case "prev": t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; break; case "first": t = 0; break; case "last": t = ts; break; default: t = parseInt(dir); break; }; var diff = Math.abs(ot-t); var speed = diff*options.speed; if(!options.vertical) { p = (t*w*-1); $("ul",obj).animate( { marginLeft: p }, { queue:false, duration:speed, complete:adjust } ); } else { p = (t*h*-1); $("ul",obj).animate( { marginTop: p }, { queue:false, duration:speed, complete:adjust } ); }; if(!options.continuous && options.controlsFade){ if(t==ts){ $("a","#"+options.nextId).hide(); $("a","#"+options.lastId).hide(); } else { $("a","#"+options.nextId).show(); $("a","#"+options.lastId).show(); }; if(t==0){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); } else { $("a","#"+options.prevId).show(); $("a","#"+options.firstId).show(); }; }; if(clicked) clearTimeout(timeout); if(options.auto && dir=="next" && !clicked){; timeout = setTimeout(function(){ animate("next",false); },diff*options.speed+options.pause); }; }; }; // init var timeout; if(options.auto){; timeout = setTimeout(function(){ animate("next",false); },options.pause); }; if(options.numeric) setCurrent(0); if(!options.continuous && options.controlsFade){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); }; }); }; })(jQuery); and here is my CSS: Code: #photos{ background-color: #453F33; width: 875px; height: 400px; margin-top: -5px; position: relative; } #slider{ padding-top:50px; margin-left: 180px; } /* image replacement */ .graphic, #prevBtn, #nextBtn, #slider1prev, #slider1next{ margin:0; padding:0; display:block; overflow:hidden; text-indent:-8000px; } #content{ position:relative; } /* Easy Slider */ #slider ul, #slider li, #slider2 ul, #slider2 li{ margin:0; padding:0; list-style:none; } #slider2{margin-top:1em;} #slider li, #slider2 li{ width:500px; height:312px; overflow:hidden; } #prevBtn, #nextBtn, #slider1next, #slider1prev{ display:block; position:absolute; top:170px; left: 40px; } #nextBtn, #slider1next{ left:780px; } #prevBtn a, #nextBtn a, #slider1next a, #slider1prev a{ display:block; position:relative; width:60px; height:77px; background:url(../images/btn_prev.jpg) no-repeat 0 0; } #nextBtn a, #slider1next a{ background:url(../images/btn_next.jpg) no-repeat 0 0; } /* numeric controls */ ol#controls{ margin:1em 0; padding:0; height:28px; margin-left: 650px; } ol#controls li{ margin:0 10px 0 0; padding:0; float:left; list-style:none; height:28px; line-height:28px; display: inline; } ol#controls li a{ float:left; height:28px; line-height:28px; background:#A6000E; color: #FFF; padding:0 10px; text-decoration:none; margin-top: -360px; } ol#controls li.current a{ background:#A1DFC6; color:#fff; } ol#controls li a:focus, #prevBtn a:focus, #nextBtn a:focus{ outline:none; } #slider li span { display: block; width: inherit; height:30px; margin-top: -317px; color: #000; padding-top: 10px; padding-left: 5px; overflow:hidden; overflow-y: hidden; overflow-x: hidden; filter:alpha(opacity=70); -moz-opacity:0.7; -khtml-opacity: 0.7; opacity: 0.7; background-color: #B1AA9A; } And you can view my site in the wild at www.ibikeseoul.com hi, I have to dynamically add images into a div. I am able to do this and perform action on the image locally. If i host it to the server iam not able to see the image it only displays x. But i am able to perform some action on the newly added image. Following is the code i have tested offline and online Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JavaScript: Moving an Image</title> <script language="javascript" type="text/javascript"> var currImage=null; var maxWidth=100; var maxHeight=100; var fileTypes=["bmp","gif","png","jpg","jpeg"]; function preview(what) { var source=what.value; var imgW,imgH, path; var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase(); for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break; if (i<fileTypes.length) { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue').value -1)+ 2; numi.value = num; var newImg = document.createElement('img'); path = source.replace(/\\/g, '/'); // Fix Windows paths path = 'file://localhost/'+ path; path = path.toLowerCase(); newImg.src=path; alert(path); newImg.id="imgID"+num; ni.appendChild(newImg); var x=parseInt(newImg.width); var y=parseInt(newImg.height); if (x>maxWidth) { y*=maxWidth/x; x=maxWidth; } if (y>maxHeight) { x*=maxHeight/y; y=maxHeight; } newImg.width=x; newImg.height=y; } else { alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", ")); } } function removeImage() { var ni = document.getElementById('myDiv'); if (currImage==null) { alert("No image to remove"); } else if (currImage==0) { alert("Click the image to remove / No image to remove"); } else { alert(currImage.id); ni.removeChild(currImage); currImage=0; } } </script> <style> #myDiv { width: 200px; height: 240px; position: relative; margin: 20px auto 0px auto; border: 5px outset #000; overflow: hidden; background-color:pink; } </style> </head> <body > <div id="myDiv" > </div> <p> <input type="hidden" value="0" id="theValue" /> <input type="button" id="delete" value="Remove" onClick="removeImage()"> <input type="file" id="picField" onChange="preview(this)"> </p> </body> </html> Hi everyone, My page with my slideshow (with lightbox integrated) is up and running fine on browsers like Firefox, IE, and Google Chrome... But Safari doesn't even show the slideshow. www.bobbivanstudio.com/work.php Any ideas why? Thanks in advance! Title explains it really. The button I am using working perfecting in FireFox and Chrome but not in Internet explorer. (Yes I know someone that actually uses IE that pointed this out to me) The rest of the code works fine but just not the reset button I have. Something I have been needing to do is make the code call my images differently by putting them in an array so I don't mess this the sources of my images like I sloppily am here, but I am not sure if that will actually fix the problem I am have. The checkbox should both uncheck the box(if checked) AND change the picture but it only unchecks the box. Here is the relevant code let me know if you want me to post the whole thing. Code: function reset(){ cb1.checked=false; document.goodAfternoon.src=goodAfternoonFinal.src; } Code: "Check" me out;) <input type="checkbox" id="cb1" onClick="validate()" /> <img src="Good Afternoon.gif" name="goodAfternoon"> <input type="button" id="cb2" value="RESET" onClick="reset()"/> I am using javascript to change the buttons on my website so that they load up a different image when hot spots on the buttons are hovered over. Everything has been working great, but this morning I tried checking out my site and for some reason the javascript wasn't working in Chrome, or on my iphone using Safari. I tried it in IE and everything still works. Any ideas on why it would stop working for those two browsers? Here is the javascript: Code: function init(){ document.getElementsByTagName('area')[0].onmouseover=function(){ document.getElementById('crocodileImg').src='Images/crocodileHover.png'; this.onmouseout=function() { document.getElementById('crocodileImg').src='Images/crocodile.png'; } } document.getElementsByTagName('area')[1].onmouseover=function(){ document.getElementById('historyImg').src='Images/historyHover.jpg'; this.onmouseout=function() { document.getElementById('historyImg').src='Images/history.jpg'; } } document.getElementsByTagName('area')[2].onmouseover=function(){ document.getElementById('applyImg').src='Images/applyHover.jpg'; this.onmouseout=function() { document.getElementById('applyImg').src='Images/apply.jpg'; } } document.getElementsByTagName('area')[3].onmouseover=function(){ document.getElementById('applyImg').src='Images/membersHover.jpg'; this.onmouseout=function() { document.getElementById('applyImg').src='Images/apply.jpg'; } } document.getElementsByTagName('area')[4].onmouseover=function(){ document.getElementById('mediaImg').src='Images/mediaHover.jpg'; this.onmouseout=function() { document.getElementById('mediaImg').src='Images/media.jpg'; } } } if(window.addEventListener){ window.addEventListener('load',init,false); } else { if(window.attachEvent){ window.attachEvent('onload',init); } } I'm not sure if seeing the html the js is referencing will help at all, but here it is just in case: Code: <div id="crocodile"> <img id="crocodileImg" src="Images/crocodile.png" usemap="#crocodileImg" border="0" width="436" height="147" alt="Home" /> <map id="crocodileImg" name="crocodileImg"> <area id="crocArea" shape="poly" coords="41,9,23,21,20,58,40,78,72,78,82,86,88,112,117,129,140,126,257,126,274,107,274,79,401,78,420,66,419,26,404,6,369,7,366,0,294,0,291,7," href="index.html" alt="Home" title="Home" /> </map> </div> <div id="history"> <img id="historyImg" src="Images/history.jpg" usemap="#historyImg" border="0" width="350" height="256" alt="Home" /> <map id="historyImg" name="historyImg"> <area id="historyArea" shape="poly" coords="18,77,18,167,48,170,79,208,124,233,174,238,228,218,257,188,266,176,280,184,306,182,338,102,331,93,271,92,254,54,226,27,196,11,169,4,137,7,109,17,82,33,65,51,52,74," href="history2.html" alt="History" title="History" /> </map> </div> <div id="apply"> <img id="applyImg" src="Images/apply.jpg" usemap="#applyImg" border="0" width="280" height="223" alt="Apply" /> <map id="applyImg" name="applyImg"> <area id="applyArea" shape="poly" coords="17,43,17,57,15,72,20,84,39,83,43,79,56,76,62,62,65,49,77,42,76,36,70,22,65,14,52,14,45,21,38,24,31,32," href="apply.html" alt="Apply" title="Apply" /> <area id="membersImg" shape="poly" coords="112,49,97,55,77,71,64,89,61,99,47,104,44,123,44,149,46,164,57,168,70,172,82,186,102,197,125,206,146,208,168,201,188,189,201,177,208,166,231,165,254,165,260,150,262,133,262,113,254,97,238,95,221,97,213,97,205,85,197,74,183,63,172,55,159,51,145,48,134,47,"href="members.html" alt="Members" title="Members" /> </map> </div> <div id="media"> <img id="mediaImg" src="Images/media.jpg" usemap="#mediaImg" border="0" width="182" height="149" alt="Media" /> <map id="mediaImg" name="mediaImg"> <area id="mediaArea" shape="poly" coords="0,102,16,103,26,117,44,129,67,133,92,128,108,115,118,102,165,102,170,88,173,65,172,52,161,49,141,49,132,42,121,42,110,30,96,22,76,16,60,14,44,18,30,29,19,36,13,48,0,51," href="media.html" alt="Media" title="Media" /> </map> </div> Thank you for any replies. Is there a way to bounce my image scroller back to the left using object.watch() or something?! at the moment, it reaches the end and stops here is my code from www.dyn-web.com Code: /************************************************************************* This code is from Dynamic Web Coding at www.dyn-web.com Copyright 2001-4 by Sharon Paine See Terms of Use at www.dyn-web.com/bus/terms.html regarding conditions under which you may use this code. This notice must be retained in the code as is! *************************************************************************/ /* dw_hoverscroll.js version date: June 2004 mouseover scrolling for dw_scrollObj (in dw_scrollObj.js) */ dw_scrollObj.stopScroll = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].endScroll(); } // increase speed onmousedown of scroll links dw_scrollObj.doubleSpeed = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed *= 2; } dw_scrollObj.resetSpeed = function(wnId) { if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed /= 2; } // algorithms for time-based scrolling and scrolling onmouseover at any angle adapted from youngpup.net dw_scrollObj.initScroll = function(wnId, deg, sp) { if ( dw_scrollObjs[wnId] ) { var cosine, sine; if (typeof deg == "string") { switch (deg) { case "up" : deg = 90; break; case "down" : deg = 270; break; case "left" : deg = 180; break; case "right" : deg = 0; break; default: alert("Direction of scroll in mouseover scroll links should be 'up', 'down', 'left', 'right' or number: 0 to 360."); } } deg = deg % 360; if (deg % 90 == 0) { cosine = (deg == 0)? -1: (deg == 180)? 1: 0; sine = (deg == 90)? 1: (deg == 270)? -1: 0; } else { var angle = deg * Math.PI/180; cosine = -Math.cos(angle); sine = Math.sin(angle); } dw_scrollObjs[wnId].fx = cosine / ( Math.abs(cosine) + Math.abs(sine) ); dw_scrollObjs[wnId].fy = sine / ( Math.abs(cosine) + Math.abs(sine) ); dw_scrollObjs[wnId].endX = (deg == 90 || deg == 270)? dw_scrollObjs[wnId].x: (deg < 90 || deg > 270)? -dw_scrollObjs[wnId].maxX: 0; dw_scrollObjs[wnId].endY = (deg == 0 || deg == 180)? dw_scrollObjs[wnId].y: (deg < 180)? 0: -dw_scrollObjs[wnId].maxY; dw_scrollObjs[wnId].startScroll(sp); } } // speed (optional) to override default speed (set in dw_scrollObj.speed) dw_scrollObj.prototype.startScroll = function(speed) { if (!this.ready) return; if (this.timerId) clearInterval(this.timerId); this.speed = speed || dw_scrollObj.speed; this.lyr = document.getElementById(this.lyrId); this.lastTime = ( new Date() ).getTime(); this.on_scroll_start(); this.timerId = setInterval(this.animString + ".scroll()", 10); } dw_scrollObj.prototype.scroll = function() { var now = ( new Date() ).getTime(); var d = (now - this.lastTime)/1000 * this.speed; if (d > 0) { var x = this.x + this.fx * d; var y = this.y + this.fy * d; if (this.fx == 0 || this.fy == 0) { // for horizontal or vertical scrolling if ( ( this.fx == -1 && x > -this.maxX ) || ( this.fx == 1 && x < 0 ) || ( this.fy == -1 && y > -this.maxY ) || ( this.fy == 1 && y < 0 ) ) { this.lastTime = now; this.shiftTo(this.lyr, x, y); this.on_scroll(x, y); } else { clearInterval(this.timerId); this.timerId = 0; this.shiftTo(this.lyr, this.endX, this.endY); this.on_scroll_end(this.endX, this.endY); } } else { // for scrolling at an angle (stop when reach end on one axis) if ( ( this.fx < 0 && x >= -this.maxX && this.fy < 0 && y >= -this.maxY ) || ( this.fx > 0 && x <= 0 && this.fy > 0 && y <= 0 ) || ( this.fx < 0 && x >= -this.maxX && this.fy > 0 && y <= 0 ) || ( this.fx > 0 && x <= 0 && this.fy < 0 && y >= -this.maxY ) ) { this.lastTime = now; this.shiftTo(this.lyr, x, y); this.on_scroll(x, y); } else { clearInterval(this.timerId); this.timerId = 0; this.on_scroll_end(this.x, this.y); } } } } dw_scrollObj.prototype.endScroll = function() { if (!this.ready) return; if (this.timerId) clearInterval(this.timerId); this.timerId = 0; this.lyr = null; } dw_scrollObj.prototype.on_scroll = function() {} dw_scrollObj.prototype.on_scroll_start = function() {} dw_scrollObj.prototype.on_scroll_end = function() {} This <div> layer positioned always at bottom left of the screen on scrolling (and calling some code from labpixies) works well in non-ie browsers, but in ie it requires the omission of the doctype declaration. Why? Is it possible to fix it so that it works with the doctype in ie? Code: <!doctype html> <html lang="en"> <head> <title></title> </head> <body> <div id="master" style="position: absolute; left: -120px; top: 11px; width: 350px; height: 0px"> <div id="menu" style="position: absolute; left: 117px; top: 12px"> <table border="0" width="18" cellspacing="0" cellpadding="0"> <tr> <td width="100%"> <a href="javascript:expand();" onfocus="this.blur()"> <img name="menutop" border="0" src="images/translate.gif" width="23" height="152"></a></td> </tr> </table> </div> <div id="screen" style="position: absolute; left: -138px; top: 12px; "> <table border="0" align="center" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; border:1px solid #000000;"> <tr> <td style="padding-left:0px; height:0px; line-height:15px; background-color:#000000;"> <a href="http://www.labpixies.com" style="font-family: Arial,Verdana; font-size:12px; font-weight:bold; text-align:left; text-decoration:none; color:#ffffff;"> Gadget by LabPixies.com</a></td> </tr> <tr> <td> <iframe allowtransparency="true" align="top" scrolling="no" width="256" height="135" frameborder="0" src="http://cdn.labpixies.com/campaigns/babylon/babylon.html" target="_self"> </iframe></td> </tr> </table> </div> </div> <script type="text/javascript"> var sidemenu = document.getElementById('master'); function FixY() { screenWidth = screen.width; if (screenWidth == 1024) { var yside = 390; } else if (screenWidth == 1152) { var yside = 400; } else if (screenWidth == 1280) { var yside = 400; } else { var yside = 450; } if(document.body.scrollTop != "undefined") sidemenu.style.top = document.body.scrollTop+yside+'px'; else sidemenu.style.top = window.pageYOffset+yside+'px'; } setInterval("FixY()",100); </script> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </body> </html> http://rs-downfall.com/scripts/graph/players.php I have this page.. If you view the source there is more data in the dataset than is being displayed on the graph.. Anyone know what the problem is? I have a simple mobile app designed using PhoneGap. I am some mp3 in it and I am using the Media plugin of PhoneGap. Everything is working fine, the audio is playing and so on. The issue, I noticed after playing 8-12 times, the audio stops playing. I do not get sound. Here are my codes: Code: <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() {} // Audio player var media = null; var audioP = false; // Play audio function playAudio(src) { if (audioP === false) { media = new Media(src, onSuccess, onError); media.play(); audioP = true; } else { media.release(); } } // onSuccess Callback function onSuccess() { console.log("playAudio():Audio Success"); audioP = false; } // onError Callback function onError(error) {} </script> Help! I have a script that works until I add the clearInterval command, and I am not sure what I have done wrong. The code is: Code: <script type="text/javascript"> function loadChatTalkRefresh(File,ID,Msg){ var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; empress = setInterval(function(){loadChatTalkRefresh(File,ID,Msg)},3000); willow = clearInterval(empress,210000); } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> My bad if this was answered somewhere else. I did search the forums but was unable to locate an answer (It is kind of a specific question) I have an odd problem. I have the following clock script: Code: function Clock() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add lead zeros to numbers less than 10 h=checkTime(h); m=checkTime(m); s=checkTime(s); document.getElementById('Clock').innerHTML=h+":"+m+":"+s; t=setTimeout('Clock'), 500); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } Loaded at the page load and assigned to a div: Code: <body onLoad = "Clock();"> <!--the clock--> <div align = "right" id = "Clock"></div> With this style applied: Code: #Clock {font-size: 30pt; position: fixed; top: 0px; right: 0px; background: #ffffff; z-index: 3; } The problem I've run into is this: In Chrome, whenever I scroll down, even by just one tap/click of the down arrow, the clock stops updating the time in, pardon the pun, real-time. But the second I scroll completely to the top of the page, it goes back to counting. I tested in the current (as of Nov 20th 2010) versions of FireFox, Opera and IE9 and the only browser that seems to produce this problem is Chrome. Any ideas? Hi All, I have written a chrome extension which will redirect to all hrefs for a given source urls in current tab.. But i don't know why all of a sudden it stops executing after reaching some page. I am attaching my code as attachment. Can any one help me out. Thanks in advance. We have a testing application that displays a timer on the screen using Javascript. It seems to be working very well. However, someone brought to my attention today that if you click-and-hold the browsers close button in the upper right corner (the X button in Windows) that the timer will stop. You can then slide your mouse cursor off of the button, and the browser will not close, but the timer was stopped for the entire time that the button was being held down. This also works for the Minimize and Maximize buttons. Is there any way at all to take care of this problem? Thanks, Jesse |