JavaScript - Getting Page Error When Clicking Link On This Javascript Rotator Script
Hello guys,
You were all very kind to help me a few months ago when I was trying to create the code which is posted below. it is a table of banner ads that will rotate on my website and the appropriate link follows the appropraite ad when they rotate. everything is working fine except that when you click on one of the ads ( which is a link), the link works but the page displays an error at the bottom as soon as any link is clicked. Since this type of hyperlink is associated with the javascript, im not sure how to correct the issue. maybe it is a simple thing. can anyone take a look at this and help me figure out the issue? thanks. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>.</title> <script type="text/javascript"> var ImageArray = [ // add paths, if needed ['randoms/0.jpg','http://0.com'], ['randoms/1.jpg','http://1.com'], ['randoms/2.jpg','http://2.com'], ['randoms/3.jpg','http://3.com'], ['randoms/4.jpg','http://4.com'], ['randoms/5.jpg','http://5.com'], ['randoms/6.jpg','http://6.com'], ['randoms/7.jpg','http://7.com'], ['randoms/8.jpg','http://8.com'], ['randoms/9.jpg','http://9.com'], ['randoms/10.jpg','http://10.com'], ['randoms/11.jpg','http://11.com'], ['randoms/12.jpg','http://12.com'], ['randoms/13.jpg','http://13.com'], ['randoms/14.jpg','http://14.com'], ['randoms/15.jpg','http://15.com'] // No comma after last entry ]; function randOrd() { return (Math.round(Math.random())-0.5); } function ChangeImages() { var ImgPtr = new Array(); for (var i=0; i<ImageArray.length; i++) { ImgPtr[i] = i; } ImgPtr = ImgPtr.sort(randOrd); var tmp = ''; for (var i=0; i<ImgPtr.length; i++) { tmp = 'tImg'+i; document.getElementById(tmp).src = ImageArray[ImgPtr[i]][0]; document.getElementById(tmp).alt = ImageArray[ImgPtr[i]][1]; tmp = 'lImg'+i; document.getElementById(tmp).href = ImageArray[ImgPtr[i]][1]; } } var TimerAction = 0; function startTimer() { TimerAction = setInterval('ChangeImages()',3000); } function stopTimer() { clearTimeout(TimerAction); } </script> <style type="text/css">body { background-color: #000000; margin: 0; } </style></head> <body onLoad="startTimer();ChangeImages()" > <table width="250" border="0" cellpadding="0" id="ads"> <tr><td> <a href="" id="lImg0" onclick="return gotoLink(this.id,0)"target="_blank"> <img id="tImg0" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg1" onclick="return gotoLink(this.id,1)"target="_blank"> <img id="tImg1" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg2" onclick="return gotoLink(this.id,2)"target="_blank"> <img id="tImg2" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg3" onclick="return gotoLink(this.id,3)"target="_blank"> <img id="tImg3" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg4" onclick="return gotoLink(this.id,4)"target="_blank"> <img id="tImg4" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg5" onclick="return gotoLink(this.id,5)"target="_blank"> <img id="tImg5" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg6" onclick="return gotoLink(this.id,6)"target="_blank"> <img id="tImg6" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg7" onclick="return gotoLink(this.id,7)"target="_blank"> <img id="tImg7" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg8" onclick="return gotoLink(this.id,8)"target="_blank"> <img id="tImg8" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg9" onclick="return gotoLink(this.id,9)"target="_blank"> <img id="tImg9" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg10" onclick="return gotoLink(this.id,10)"target="_blank"> <img id="tImg10" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg11" onclick="return gotoLink(this.id,11)"target="_blank"> <img id="tImg11" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg12" onclick="return gotoLink(this.id,12)"target="_blank"> <img id="tImg12" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg13" onclick="return gotoLink(this.id,13)"target="_blank"> <img id="tImg13" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg14" onclick="return gotoLink(this.id,14)"target="_blank"> <img id="tImg14" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg15" onclick="return gotoLink(this.id,15)"target="_blank"> <img id="tImg15" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> </table> </body> </html> Similar TutorialsI tried to word the question as best as possible, but here is what I want to do. I am creating a calculator online and it is getting more and more extensive, which is good b/c I'm learning a lot. Here is what I'm trying accomplish now. I am using "input" to get information from the user in the top section of my calculator and that will always stay the same. The part that will change is the results section (bottom part of the calc) based on a few different variations or setups, so I want to be able have them click on a few different options. Option 1 Option 2 Option 3 Depending on which one they click I want the javascript that is run for the results section to correspond to the option chosen. I also, want to be able to have a default option displayed the first time the page is loaded and then have it change if a different option is chosen. I don't think reloading the page is necessary, but I'm new to this and could use a little direction. I hope what I'd like to do makes a little sense. I'm not asking for any code written that will do this, but naturally something hints or tips that could get me going. I don't know how to "monitor" a link and return a value to a variable, so that it can be put into a an if statement in the results section. After that, it would be continually monitored or somehow restarted if the variable does change. Again, I don't know if this is the best way to go at it, but I'm not sure at all. Any help would be awesome. I have looked at "onclick", but I'm not completely sure how I can tie it all together of if I should use another method. Thanks for any suggestions/ideas/help. My site is http://gofi.netai.net/ I don't want it to completely stop or pause when the users mouse is over the page but keeps rotating. I want it to stop for good when the users mouse clicks on one of the tabs. I wanted a auto rotator so the user can see all my pages up front and fast before moving to anther site. This is snip-it of the code but you can see in the complete code in the source code. I'm new at this can you help? script type="text/javascript"> $(document).ready(function(){ $("#rotator > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 4000, true); }); Hello, Im new and need help with an image rotator script I got from "wowslider" if anyone ever heard of it. I have the following code on my website (please note that the CSS and javascript were just pre-made and I barely adjusted anything if at all; all names of the tags are not mine): 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" xml:lang="en" lang="en"> <head> <title>unnamed</title> <script src="scripts/wowslider.js" type="text/javascript"></script> <style type="text/css"> /* bottom center */ #wowslider-container1 .ws_bullets { top:0; right: 0; } #wowslider-container1 { /*overflow: hidden; */ zoom: 1; position: relative; width:1032px; margin:0 auto; z-index:100; border:none; } #wowslider-container1 .ws_images{ width:1032px; height:500px; overflow:hidden; position:relative; } #wowslider-container1 .ws_images a{ color:transparent; } #wowslider-container1 .ws_images img{ top:0; left:0; border:none 0; max-width: none; } #wowslider-container1 a{ text-decoration: none; outline: none; border: none; } #wowslider-container1 .ws_bullets { font-size: 0px; padding: 5px; float: left; position:absolute; z-index:70; top:450px; right:900px; } #wowslider-container1 .ws_bullets div{ position:relative; float:left; } #wowslider-container1 .ws_bullets a { width:22px; height:20px; background: url(images/backgrounds/bullet.png) left top; float: left; text-indent: -1000px; position:relative; color:transparent; } #wowslider-container1 .ws_bullets a.ws_selbull, #wowslider-container1 .ws_bullets a:hover{ background-position: 0 100%; } #wowslider-container1 a.ws_next, #wowslider-container1 a.ws_prev { position:absolute; display:block; top:50%; margin-top:-16px; z-index:60; height: 50px; width: 39px; background-image: url(images/backgrounds/arrows.png); } #wowslider-container1 a.ws_next{ background-position: 100% 0; right:0px; } #wowslider-container1 a.ws_prev { left:0px; background-position: 0 0; } #wowslider-container1 .ws-title{ position: absolute; bottom:7%; left: 0; margin-right:5px; z-index: 50; background: #FFF; color: #000; padding: 10px; font-size: 19px; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; text-shadow: 1px 1px 0 #fff; opacity: 0.7; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80); } #wowslider-container1 .ws-title div{ padding-top:5px; font-size: 13px; } </style> </head> <!-- Slideshow Backgrounds --> <div id="wowslider-container1"> <div class="ws_images"> <div><img src="images/backgrounds/test1.jpg" alt="test1" title="test1" id="wows0"/><span style="top:150px; right:300px; color:red; font-weight:bold;">TEXTTEXTTEXTTEXTTEXT</span></div> <div><img src="images/backgrounds/test2.jpg" alt="test2" title="test2" id="wows1"/></div> <div><img src="images/backgrounds/test3.jpg" alt="test3" title="test3" id="wows2"/></div> <div><img src="images/backgrounds/test4.jpg" alt="test4" title="test4" id="wows3"/></div> </div> <div class="ws_bullets"><div> <a href="#wows0" title="test1">1</a> <a href="#wows1" title="test2">2</a> <a href="#wows2" title="test3">3</a> <a href="#wows3" title="test4">4</a> </div> </div> <script type="text/javascript" src="scripts/wow_script.js"></script> <!-- END ROTATOR --> </body> </html> The following is the jscript used in reference (two external files): 1)wow_script.js Code: function ws_fade(b,a){var c=jQuery;a.each(function(d){if(!d){c(this).show()}else{c(this).hide()}});this.go=function(d,e){c(a.get(d)).fadeIn(b.duration);c(a.get(e)).fadeOut(b.duration);return d}};// ----------------------------------------------------------------------------------- jQuery("#wowslider-container1").wowSlider({effect:"fade",prev:"",next:"",duration:20*100,delay:90*100,outWidth:1032,outHeight:500,width:1032,height:500,autoPlay:true,stopOnHover:true,loop:false,bullets:true,caption:false,controls:true}); 2) wowslider.js Code: if(!jQuery.fn.wowSlider){jQuery.fn.wowSlider=function(b){var i=this;var g=jQuery;b=g.extend({effect:function(f,d){var t=jQuery;d.each(function(H){if(!H){t(this).show()}else{t(this).hide()}});this.go=function(H,I){t(d.get(H)).fadeIn(f.duration);t(d.get(I)).fadeOut(f.duration);return H}},prev:"",next:"",duration:1000,delay:20*100,captionDuration:1000,outWidth:960,outHeight:360,width:960,height:360,caption:true,controls:true,autoPlay:true,bullets:true,stopOnHover:0,preventCopy:1},b);b.loop=b.loop||Number.MAX_VALUE;var E=i.find(".ws_images>*");var v=E.length;b.stopOn=((b.stopOn||0)+v)%v;var D;if(b.preventCopy){D=g('<div><a href="#" style="display:none;position:absolute;left:0;top:0;width:100%;height:100%"></a></div>').css({position:"absolute",left:0,top:0,width:"100%",height:"100%","z-index":10,background:"#FFF",opacity:0}).appendTo(i).find("A").get(0)}E.each(function(f){var d=g(this).html()||"";var t=d.indexOf(">",d);if(t>=0){g(this).data("descr",d.substr(t+1));if(t<d.length-1){g(this).html(d.substr(0,t+1))}}g(this).css({"font-size":0})});var k=E.find("IMG");var a=0;function s(t,f,d){t=((t%v)+v)%v;if(a==t){return}var t=o.go(t,a,f,d);if(t<0){return}r(t);if(b.caption){j(E[t])}a=t;if(b.onStep){b.onStep(t)}}var C,A,e=0;var u=i.get(0);if(u.addEventListener){u.addEventListener("touchmove",function(t){if(e){var f=(C-t.touches[0].pageX)/20;var d=(A-t.touches[0].pageY)/20;if((Math.abs(f)>1)||(Math.abs(d)>1)){C=A=e=0;y(t,a+((f+d)>0?1:-1),f,d)}}},false);u.addEventListener("touchstart",function(d){if(d.touches.length==1){C=d.touches[0].pageX;A=d.touches[0].pageY;e=1}else{e=0}},false);u.addEventListener("touchend",function(d){e=0},false)}function r(f){if(b.bullets){n(f)}if(D){var d=E.get(f).href;if(d){D.setAttribute("href",d);D.setAttribute("target",E.get(f).target);D.style.display="block"}else{D.style.display="none"}}}var q;function z(){w();if(b.autoPlay){q=setTimeout(function(){s(a<v-1?a+1:0);if(a==b.stopOn&&!--b.loop){b.autoPlay=0}z()},b.delay+b.duration)}}function w(){if(q){clearTimeout(q)}q=null}function y(H,t,f,d){w();H.preventDefault();s(t,f,d);z()}g(k.get(0)).css("z-index",1);k.css("position","absolute");if(typeof b.effect=="string"){b.effect=window["ws_"+b.effect]}var o=new b.effect(b,k,g(".ws_images",i));E.find("IMG").css("visibility","visible");var p=c=g(".ws_images",i);var m=" ";c=m?g("<div></div>"):0;if(c){c.css({position:"absolute",right:"2px",bottom:"2px",padding:"0 0 0 0"});p.append(c)}if(c&&document.all){var B=g('<iframe src="javascript:false"></iframe>');B.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",filter:"alpha(opacity=0)"});B.attr({scrolling:"no",framespacing:0,border:0,frameBorder:"no"});c.append(B)}var F=c?g(document.createElement("A")):c;if(F){F.css({position:"relative",display:"block","background-color":"#E4EFEB",color:"#837F80","font-family":"Lucida Grande,sans-serif","font-size":"11px","font-weight":"normal","font-style":"normal","-moz-border-radius":"5px","border-radius":"5px",padding:"1px 5px",width:"auto",height:"auto",margin:"0 0 0 0",outline:"none"});F.attr({href:"http://"+m.toLowerCase()});F.html(m);F.bind("contextmenu",function(d){return false});c.append(F)}if(b.controls){var x=g('<a href="#" class="ws_next">'+b.next+"</a>");var h=g('<a href="#" class="ws_prev">'+b.prev+"</a>");i.append(x);i.append(h);x.bind("click",function(d){y(d,a+1)});h.bind("click",function(d){y(d,a-1)})}function G(){var t=i.find(".ws_bullets>div");var L=g("a",t);L.click(function(M){y(M,g(M.target).index())});var J=L.find("IMG");if(J.length){var I=g('<div class="ws_bulframe"/>').appendTo(t);var f=g("<div/>").css({width:J.length+1+"00%"}).appendTo(g("<div/>").appendTo(I));J.appendTo(f);g("<span/>").appendTo(I);var H=-1;function K(N){if(N<0){N=0}g(L.get(H)).removeClass("ws_overbull");g(L.get(N)).addClass("ws_overbull");I.show();var O={left:L.get(N).offsetLeft-I.width()/2};var M={left:-J.get(N).offsetLeft};if(H<0){I.css(O);f.css(M)}else{if(!document.all){O.opacity=1}I.stop().animate(O,"fast");f.stop().animate(M,"fast")}H=N}L.hover(function(){K(g(this).index())});var d;t.hover(function(){if(d){clearTimeout(d);d=0}K(H)},function(){L.removeClass("ws_overbull");if(document.all){if(!d){d=setTimeout(function(){I.hide();d=0},400)}}else{I.stop().animate({opacity:0},{duration:"fast",complete:function(){I.hide()}})}});t.click(function(M){y(M,g(M.target).index())})}}function n(d){g(".ws_bullets A",i).each(function(f){if(f==d){g(this).addClass("ws_selbull")}else{g(this).removeClass("ws_selbull")}})}if(b.caption){$caption=g("<div class='ws-title' style='display:none'></div>");i.append($caption);$caption.bind("mouseover",function(d){w()});$caption.bind("mouseout",function(d){z()})}function j(d){var H=g("img",d).attr("title");var t=g(d).data("descr");var f=g(".ws-title",i);f.stop(1,1).stop(1,1).fadeOut(b.captionDuration/3,function(){if(H||t){f.html((H?"<span>"+H+"</span>":"")+(t?"<div>"+t+"</div>":""));l(f,{direction:"left",easing:"easeInOutExpo",complete:function(){if(g.browser.msie){f.get(0).style.removeAttribute("filter")}},duration:b.captionDuration})}})}if(b.bullets){G()}r(0);if(b.caption){j(E[0])}if(b.stopOnHover){this.bind("mouseover",function(d){w()});this.bind("mouseout",function(d){z()})}z();function l(K,P){var M={};var N=["position","top","bottom","left","right"];for(var L=0;L<N.length;L++){M[N[L]]=K[0].style[N[L]]}K.show();var J={width:K.outerWidth(true),height:K.outerHeight(true),"float":K.css("float"),overflow:"hidden",left:K.position().left,top:K.position().top,opacity:0},f=g("<div></div>").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});K.wrap(f);f=K.parent();if(K.css("position")=="static"){f.css({position:"relative"});K.css({position:"relative"})}else{g.extend(J,{position:K.css("position"),zIndex:K.css("z-index")});K.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}f.css(J).show();var O=P.direction||"left";var t=(O=="up"||O=="down")?"top":"left";var H=(O=="up"||O=="left");var d=P.distance||(t=="top"?K.outerHeight({margin:true}):K.outerWidth({margin:true}));K.css(t,H?(isNaN(d)?"-"+d:-d):d);var I={};I[t]=(H?"+=":"-=")+d;f.animate({opacity:1},{duration:P.duration,easing:P.easing});K.animate(I,{queue:false,duration:P.duration,easing:P.easing,complete:function(){for(var Q in M){K[0].style[Q]=M[Q]}K.parent().replaceWith(K);if(P.complete){P.complete()}}})}return this}}jQuery.extend(jQuery.easing,{easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a}}); The rotator works perfectly with fading the images referenced in and out and the bullets for switching between images works great too, however I am looking to place text OVER the images so it can be highlighted/copied/etc. When I tried to put a SPAN in the code DIV the text I put into the SPAN (i.e. "TEXTTEXTTEXTTEXTTEXT") doesnt appear over the image. I dont know what else to do and Im not sure if its a javascript issue OR a coding issue within the page. Any ideas? Thanks NOTE: To be clear, I want four images, rotating, with four different text pieces to be placed OVER each image. So when one image rotates, its text change as well (to the next image and next set of text). I have a banner ad with an image rotation embedded in a DIV. It works quite fine, but doesn't have required SEO info, ie: alt text. Here is the code that is working. Code: <div style="background-image: url(http://www.earthwindwater.com.au/banners/skiracersworld/banner-bg.png);height:148px;width:982px;border:0px;"> <div style="float:left;height:148px;border:0px;"> <a href="http://www.earthwindwater.com.au" target="_blank"><img border=0 align="absmiddle" alt="Earth Wind and Water Sports Action Cameras" src="http://www.earthwindwater.com.au/banners/skiracersworld/EWW-logo.png" /></a> </div> <div style="height:148px;border:0px;float:right;padding-right:415px; "> <a id="imageurl" target="_blank" ><img id="Rotating1" border="0"></img></a> <script language="JavaScript"> function RotateImages(Start) { var a = new Array("http://www.earthwindwater.com.au/banners/skiracersworld/Contour+.png","http://www.earthwindwater.com.au/banners/skiracersworld/LiquidImage.png","http://www.earthwindwater.com.au/banners/skiracersworld/ContourGPS.png", "http://www.earthwindwater.com.au/banners/skiracersworld/GoPro.png"); var c = new Array("http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/contour", "http://www.earthwindwater.com.au/store/cameras/hd-cameras/impact-series-720p-mx-goggle-red", "http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/contourgps", "http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/gopro-hd-motorsports-hero"); var b = document.getElementById('Rotating1'); var d = document.getElementById('imageurl'); if(Start>=a.length) Start=0; b.src = a[Start]; d.href = c[Start]; window.setTimeout("RotateImages(" + (Start+1) + ")",5000); } RotateImages(0); </script> </div> </div> Now, I thought I would modify the code a little and include "Image Title" and "ALT Text" I am not much of a scripting genius, therefore my modifications don't work. Here is my modified code Code: <div style="background-image: url(http://www.earthwindwater.com.au/banners/skiracersworld/banner-bg.png);height:148px;width:982px;border:0px;"> <div style="float:left;height:148px;border:0px;"> <a href="http://www.earthwindwater.com.au" target="_blank"><img border=0 align="absmiddle" alt="Earth Wind and Water Sports Action Cameras" src="http://www.earthwindwater.com.au/banners/skiracersworld/EWW-logo.png" /></a> </div> <div style="height:148px;border:0px;float:right;padding-right:415px; "> <a id="imageurl" target="_blank" ><img id="Rotating1" id="imagealt" id="imagetitle" border="0"></img></a> <script language="JavaScript"> function RotateImages(Start) { var a = new Array("http://www.earthwindwater.com.au/banners/skiracersworld/Contour+.png","http://www.earthwindwater.com.au/banners/skiracersworld/LiquidImage.png","http://www.earthwindwater.com.au/banners/skiracersworld/ContourGPS.png", "http://www.earthwindwater.com.au/banners/skiracersworld/GoProHDHERO2.png"); var c = new Array("http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/contour", "http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/impact-series-hd-1080p-mx-video-goggle-white", "http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/contourgps", "http://www.earthwindwater.com.au/store/cameras/full-hd-cameras/gopro-hd-hero2-motorsports-edition"); var e = new Array("Contour+", "Impact Series HD 1080p MX Video Goggle", "ContourGPS", "GoPro HD HERO2 Motorsport Edition"); var g = new Array("Contour+", "Impact Series HD 1080p MX Video Goggle", "ContourGPS", "GoPro HD HERO2 Motorsport Edition"); var b = document.getElementById('Rotating1'); var d = document.getElementById('imageurl'); var f = document.getElementById('imagealt'); var h = document.getElementById('imagetitle'); if(Start>=a.length) Start=0; b.src = a[Start]; d.href = c[Start]; f.alt = e[Start]; h.title = g[Start]; window.setTimeout("RotateImages(" + (Start+1) + ")",5000); } RotateImages(0); </script> </div> </div> Any ideas how I can get this to work hello, It is a insult to newbie to cal myself one, but I have a blog that I am trying to get a simple bit of code to work on. I have text rotator that I found and have made it work for my purposes, but I need it to pause when someone mouses over and restart when then mouse off. I have found code snipets online but I am not smart enough to figure out where they fit in....Help would be very appreciated the code it below.... Code: <div id="quotetext" > text </div> <script type="text/javascript" > var myquotes = new Array( 'quote 1', 'quote 2', 'qoute 3' ); function rotatequote() { thequote = myquotes.shift(); //Pull the top one myquotes.push(thequote); //And add it back to the end document.getElementById('quotetext').innerHTML = thequote; // This rotates the quote every 10 seconds. // Replace 10000 with (the number of seconds you want) * 1000 t=setTimeout("rotatequote()",5000); } // Start the first rotation. rotatequote(); </script> I recently uploaded my site from locally to a remote host. After uploading I noticed my ad block detection system stopped working as well as my banner rotation script. First off, I used the banner rotation script shown demo'd he http://labs.beacon9.ca/bannerRotator/ Now if you look at the source of that page you can see how the javascript works by including the BannerRotator.js. On my website, I stuck the jQuery "module" in a folder called "simple" and went from that route. If you look on my site: http://www.flex-essentials.com you can see that on the home page there is a large grey box where the banner rotator script should be, but is not. I'm using this "ready" function by jquery to load some things: Code: $(document).ready(function($) { bannerRotator('#bannerRotator', 500, 5000, true); $('a[rel*=facebox]').facebox(); if ($("#advert").height() == "0" || $("#advert").css("display") == "none"){//enabled $("#lolaa").css("display", "block"); $("#lolaa").css("height", "90px"); } else if($("#advert").height() != "0" || $("#advert").css("display") != "none"){//disabled $("#lolaa").css("height", "0"); $("#lolaa").css("display", "none"); } if($("#BodyAd").height() == "0" || $("#BodyAd").css("display") == "none"){//enabled $("#wtlt_cube").css("display", "block"); $("#wtlt_cube").css("height", "213px"); } else if($("#BodyAd").height() != "0" || $("#BodyAd").css("display") != "none"){//disabled $("#wtlt_cube").css("height", "0"); $("#wtlt_cube").css("display", "none"); } }); But for some reason, the only javascript code that is working is the "facebox" module. Please help me figure out why this javascript isnt loading. Thanks! Sup gents. Im trying to wrap some html code inside javascript. Problem is i want the picture here to link me to another page, im inserting the link command inside the picture tag put still the link isnt happening. Ive written in a wrong way? Code: document.writeln('<div id="Apartments"><table width="512" height="723" bgcolor="#666633">\n\n <tr>\n <th width="269" height="246" scope="col"><table width="243" height="208" border="1">\n <tr>\n <th height="23" colspan="2" scope="col">Apartment Fola<\/th>\n <\/tr>\n <tr>\n\n <td height="23" colspan="2"><img src="Images\/tn_G1-pokoj.jpg" alt="Fola" width="235" height="139" <a href="apartmentfola.html">/a> <\/> Hi all, I want to have a javascript popup box so that when a hyperlink is clicked, a user is asked if they are sure they want to click this link, if they select ok then the page loads, if they click canel then nothing happens, so i have this code below: Code: <script type="text/javascript"> function confirmSubmit() { var agree=confirm("Are you sure you wish to click this link?"); if (agree) return true ; else return false ; } </script> Code: <a onclick="return confirmSubmit()" href="page.html">Page</a> However when a user clicks cancel the link still loads, can anyone see where I am going wrong? any help will be appreciated Hello. I have looked everywhere and I absolutely cannot find a method that works. I'm making an html website with flash. This is all I want...... A swf "this will be the default flash you see" underneath that flash I want 3 text links named..... Flash1 Flash2 Flash3 when you click flash1, 2, or 3 I want it to swap out the Current flash video with a different one. This way The user can watch all the flash vids on the same page, rather than a separate page for each flash. I found a way to swap them out using iframe, however that requires me to make a separate html page for each of my swf's themselves. I dont want to do that. Plz if someone could help me I would greatly appreciate it! I hope I am posting this in the correct section, I know swfobject involves javascripting so thats why I'm posting here. Not that your method HAS to involve swfobject to embed. If someone can give me code that I can just copy/paste into a blank page in dreamweaver (and I would adjust the embded swf file name and size etc obviously) and have it work that would be fantastic. thank you How to get this to work? Code: <html> <body> <script type="text/javascript" src="01.js"> <h1>Welcome</h1> <a href="#" onclick="write(); return false;">Click here</a> <div id="info_here"> </div> </body> </html> 01.js Code: function write() { var a=document.getElementById("info_here"); a.innerHTML=document.write("Hello <br />" + "Thanks for clicking"); } Hi, I have a little problem with placing a javascript into a php script If the action "Change" is true then I want to open a new window with a javascript below. I get an error message: Parse error: syntax error, unexpected '<' in /home/........ on line xx On that xx line starts the Javascript What must I do to solve this problem. <?php.................... if($_REQUEST['action']=="Change") { mysql_query("UPDATE Persons SET Itemstate = '{$_REQUEST['Nr']};' WHERE Nr={$_REQUEST['Nr']};"); <SCRIPT LANGUAGE="javascript"> <!-- window.open ('Examplepage.html') --> </SCRIPT> ........ ?> I want to make a script selecting electronics category in this site http://eu.redeem-it.net/boutique.php A friend told me to use getElementsByClass but I still cant do it. Hi Im alot stuck at the moment so if anyone can help resolve the issues i'm having I would be very grateful! if you go to http://love2-create.com and click on the orange "view profile" link about halfway down the left hand column, a tab opens showing a profile with a small picture gallery at the bottom, this gallery works fine in firefox and google chrome, however in safari it works sometimes but not always and in IE it usually works on the first time the page is loaded but then when the page is refreshed and the profile link is clicked I get an Error: 'document.getElementById(...)' is null or not an object on line 60, the lines in question look like this: Code: buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div") for (var i=0; i<alldivs.length; i++){ if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv" setting.contentdivs.push(alldivs[i]) alldivs[i].style.display="none" //collapse all content DIVs to begin with } } }, Does anyone know why this may be, and how it can possibly work sometimes but not always?? its totally got me baffled so if anyone can help I would very very much appreciate it, please let me know if you need any other details about the site etc from me. Regards, Keir Hello, I hope you can help me, I have used a really simple image script which features 3 thumbnails, you click one thumbnail and it loads the image as a larger image. Works perfectly in Google Chrome, Firefox - and then I've come to try in IE8... works perfect BUT javascript error as follows: - Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; InfoPath.2; .NET4.0C) Timestamp: Fri, 31 Dec 2010 17:14:48 UTC Message: 'document.images.image0' is null or not an object Line: 13 Char: 1 Code: 0 Here is the code, what am I doing wrong? I can't spot it, theres a couple of threads online from 2005 about this script but none have helped me clear the error. Code: <html> <head> <script language="JavaScript"> image0 =new Image(); image1 =new Image(); image2 =new Image(); image0.src ="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" image1.src ="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" image2.src ="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" document.images['image0'].src=image0.src; document.images['image1'].src=image1.src; document.images['image2'].src=image2.src; function image_click(clicks) { if(clicks==0){document.images['large'].src=image0.src;} if(clicks==1){document.images['large'].src=image1.src;} if(clicks==2){document.images['large'].src=image2.src;} } </script> </head> <body> <a href="javascript:image_click(0)"><img src="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" height="93" width="123" alt="" name="image0" border="0"/></a> <a href="javascript:image_click(1)"><img src="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" width="123" alt="" name="image1" border="0"/></a> <a href="javascript:image_click(2)"><img src="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" height="93" width="123" alt="" name="image2" border="0"/></a> <img src="http://ec.europa.eu/information_society/activities/egovernment/images/project_logos/sample.jpg" align="middle" border="0" width="418" height="284" name="large"> </body> </html> I am a new to js and GM but I am trying to make a script that will click a button on a page where there are multiple instances of the button. The source I am looking at is below and I have narrowed down what I am looking at to the bold section. <dl> <dd class="left"><div id='recommendstatus_article4458331'> <dl class="recommend"> <dt class='recs'><a href="javascript://" onclick="RecSpy( 'article', '4458331', 'tippers' ); return false;">50</a> </dt> <dd><a href="javascript:void(0);" onclick="RecommendItem(1,'article','4458331','1','recommendstatus_article4458331' ); return false;" onmouseover="return overlib('Give thumbs up', WRAP);" onmouseout="return nd();"> <img class='icon' title='' alt='Thumb up' style='background-position: -304px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a></dd> <dt class='tippers'><a href="javascript://" style='color: #969600;' onclick="RecSpy( 'article', '4458331', 'tippers' ); return false;"></a></dt> <dd><a href="javascript:void(0);" onmouseover = "return overlib( 'GeekGold Tip', WRAP );" onmouseout = "nd();" onClick="GeekGoldTip(0,'article','4458331','recommendstatus_article4458331'); return false;"> <img class='icon' title='' alt='tip' style='background-position: -368px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a></dd> <dd> <a href="javascript:void(0);" onclick="RecommendItem(0,'article','4458331','','recommendstatus_article4458331', 'article4458331' ); return false;" onmouseover="return overlib('Hide this post', WRAP);" onmouseout="return nd();"> <img class='icon' title='' alt='Thumb up' style='background-position: -336px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a> </dd> <dt class='thumbsdown'> </dt> </dl> How do I create a script to find each instance of the button and click it? For school I'm supposed to write a JS code which visits a website, and then clicks on a button on that website. I used the document.location method to visit the web page, but then if I use the document.forms[0].elements[0].click() function to click a button, nothing happens. The click() function has always worked for me when the JS code is embedded in the web page, but its not in this case because the code has to click a button on an external website. So how can I do this? I just need me Javscript program to visit a site, and then click a button on that site. Please help, thanks.
Is there a way to use inline javascript that will prevent any javascript after it (in the same page) from executing? So, for instance I could have something like: -Content- -JS A- -Content- -JS B- -JS C- 'JS A' would execute, 'JS B' would be the code I'm asking about and it would cause 'JS C' to not do anything. Sorry if this is an off-the-wall question. I good with C/C++, VB, Ruby, Lua, HTML, etc, but I haven't gotten to Javascript (or Java) yet so I have no idea what the capabilities or environment setup are like. Thanks in advance for any advice. I am trying to figure out how to code this type of horizontal navigation like this site. http://www.maxdesign.com.au/ When you click on, say, "News", the CSS button turns red and white. I am thinking that this is done with JavaScript and a basic CSS list menu. But I cannot seem to find an example of this the of menu anywhere. The Max Design site is based on WordPress and apparently this navigation uses an API built into the WP framework. I need this type of horizontal menu for a custom coded CSS and PHP site. Any and all help would be appreciated. Either code or point me to a tutorial. Thanks, WiLd hi please help solving my problem. I have the following code for changing the td colour when chk box in it is clicked. It is working fine. My application will get some data from the database when i check a chk box say ABC. My problem is ...i want to chage the colour of the check box when it is clicked and retain the colour of my chkbox even after page refresh. Code: <html> <head> <title>color</title> <script type="text/javascript"> function toggle(box,theId) { if(document.getElementById) { var cell = document.getElementById(theId); if(box.checked) { cell.className = "on"; } else { cell.className = "off"; } } } </script> <style type="text/css"> .off { background-color: #fff; } .on { background-color: red; } </style> </head> <body> <table border="1" cellpadding="5" cellspacing="0"> <tr> <td class="off" id="sub1"><input type="checkbox" name="subject" onclick="submit(); toggle(this,'sub1'); " value="s1" id="demo1">ABC</td> <td class="off" id="sub2"><input type="checkbox" name="subject" onclick=" submit(); toggle(this,'sub2'); " value="s2" id="demo2">XYZ</td> </tr> </table> </body> </html> Reply With Quote 01-21-2015, 08:37 AM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Originally Posted by raj_d hi please help solving my problem. I have the following code for changing the td colour when chk box in it is clicked. It is working fine. My application will get some data from the database when i check a chk box say ABC. My problem is ...i want to chage the colour of the check box when it is clicked and retain the colour of my chkbox even after page refresh. You will need to use a cookie or local storage to record the colour of the checkbox. |