JavaScript - How To Make Marquee Pause Onmouseover
Hi,
We have a marquee that we use occasionally at work when we want to announce something important. The text is dynamic and will sometimes contain links. I need to make it so that the marquee stops when you mouseover it and then begins again when you mouseout. I can get this to work just fine. The problem is, I want the pause to happen when you hover over the text ONLY, not the entire 690 width TD! I tried wrapping a span around the text and putting an action on it, but the marquee still stops even when you have your cursor out in never-never land to the right. Does anyone know how to make this work in IE without using a huge JavaScript file like on Dynamic Drive? Code: <td width="690" valign="middle" class="headerNewsFlash"> <marquee onMouseOver="this.stop();" onMouseOut="this.start();" scrolldelay="0" scrollamount="4">News Flash Text Goes Here</marquee> </td> Thanks! Similar TutorialsHi, I found a nice simple javascript slider but there is a small change I want to make. How can I make the slider pause for one or two seconds when the image has slid fully into position ? PHP Code: <style> #ParentDiv { margin: auto; width: 200px; overflow: hidden; } #ChildDiv { width: 6000px; position:relative; cursor:pointer; } #ParentDiv img { float: left; padding: 3px; margin: 0px; } </style> <script type="text/javascript"> //Array Of Image, [URL, width of Image, LinkTo] var t; var StepTime=20; var StepPixel=2; var ImgPadding=3; var ParentDivLen=200; var Img= Array( ["http://mobi6.net/images/screen1.png", 200, "index.php"], ["http://mobi6.net/images/screen2.png", 200, "index.php"], ["http://mobi6.net/images/screen3.png", 200, "index.php"], ["http://mobi6.net/images/screen1.png", 200, "index.php"], ["http://mobi6.net/images/screen2.png", 200, "index.php"], ["http://mobi6.net/images/screen3.png", 200, "index.php"], ["http://mobi6.net/images/screen1.png", 200, "index.php"], ["http://mobi6.net/images/screen2.png", 200, "index.php"], ["http://mobi6.net/images/screen3.png", 200, "index.php"] ); var Pos=3; var Len=Img.length; var DivWidth=0; var MoreImage=0; function goURL(URLS) { document.location.href=URLS; } for(i=0;i<Len;i++) { DivWidth+=Img[i][1] + ImgPadding*2; if(MoreImage==0 && DivWidth>ParentDivLen)MoreImage=i; } function getE(id) { return document.getElementById(id); } function Dr_Img(IMG) { return '<img src="'+ IMG[0] + '" onclick="goURL(\'' + IMG[2] + '\')">'; } function Dr_ImgArr() { var str=''; for(i=0;i<Len;i++) str += Dr_Img(Img[i]); for(i=0;i<MoreImage;i++)str += Dr_Img(Img[i]); document.write(str); } function DoSlide() { if(Pos==0)Pos=-1; divtg=getE('ChildDiv'); Pos-=StepPixel; if(Pos<-DivWidth)Pos=0; divtg.style.left=Pos +'px'; t=setTimeout('DoSlide()',StepTime); } function SlideStop() { clearTimeout(t); } function setmouse(id) { if(id==1) { DoSlide(); } else { SlideStop(); } } </script> </head> <body onload="DoSlide()"> <div id="ParentDiv"> <div id="ChildDiv" onmouseout="setmouse(1);" onmouseover="setmouse(2);"> <script> Dr_ImgArr(); </script> </div> </div> I have tried adding wait(2) in a couple of places but the script just failed to run. Any ideas ? Thanks. . Instead of using setTimeout() or setInterval(), I wrote a function like this: Code: function pause(time) { var currentTime=(new Date()).getTime(); while (currentTime+time > (new Date()).getTime()); } However, it doesn't work as expected. if you append a character to the value of button, you will get the result at one time. e.g. Code: for (var i=0; i<5; i++) { aButton.value+="2 "; pause(2000); } then the webpage wait 10 secs then display 2 2 2 2 2 while it should append '2' every 2 secs ... so is there real pause mechanism in js? (besides alert() etc which makes the background totally blank...) I have some text that I don't want to display until 2 seconds after the previous text. The sleep(2); function won't work for what I am doing.
I have a site with a lot of animated gifs and I was wondering if there was a way to (on page load) stop all gif animations (only show first image frame). Then when you click a link, it will animate the animated gifs.
I have a banner but it keeps rotating even when you mouse over it. Is there a simple code I can add to the code below so that the banner will paused when you mouse over it? Thanks! Jeremy Quote: </script> <script type="text/javascript"> $(function() { //some elements.. var $ps_container = $('#ps_container'), $ps_image_wrapper = $ps_container.find('.ps_image_wrapper'), $ps_next = $ps_container.find('.ps_next'), $ps_prev = $ps_container.find('.ps_prev'), $ps_nav = $ps_container.find('.ps_nav'), $tooltip = $ps_container.find('.ps_preview'), $ps_preview_wrapper = $tooltip.find('.ps_preview_wrapper'), $links = $ps_nav.children('li').not($tooltip), total_images = $links.length, currentHovered = -1, current = 0, $loader = $('#loader'); /*check if you are using a browser*/ var ie = false; if ($.browser.msie) { ie = true;//you are not!Anyway let's give it a try } if(!ie) $tooltip.css({ opacity : 0 }).show(); /*first preload images (thumbs and large images)*/ var loaded = 0; $links.each(function(i){ var $link = $(this); $link.find('a').preload({ onComplete : function(){ ++loaded; if(loaded == total_images){ //all images preloaded, //show ps_container and initialize events $loader.hide(); $ps_container.show(); //when mouse enters the pages (the dots), //show the tooltip, //when mouse leaves hide the tooltip, //clicking on one will display the respective image $links.bind('mouseenter',showTooltip) .bind('mouseleave',hideTooltip) .bind('click',showImage); //navigate through the images $ps_next.bind('click',nextImage); $ps_prev.bind('click',prevImage); } } }); }); function showTooltip(){ var $link = $(this), idx = $link.index(), linkOuterWidth = $link.outerWidth(), //this holds the left value for the next position //of the tooltip left = parseFloat(idx * linkOuterWidth) - $tooltip.width()/2 + linkOuterWidth/2, //the thumb image source $thumb = $link.find('a').attr('rel'), imageLeft; //if we are not hovering the current one if(currentHovered != idx){ //check if we will animate left->right or right->left if(currentHovered != -1){ if(currentHovered < idx){ imageLeft = 75; } else{ imageLeft = -75; } } currentHovered = idx; //the next thumb image to be shown in the tooltip var $newImage = $('<img/>').css('left','0px') .attr('src',$thumb); //if theres more than 1 image //(if we would move the mouse too fast it would probably happen) //then remove the oldest one (:last) if($ps_preview_wrapper.children().length > 1) $ps_preview_wrapper.children(':last').remove(); //prepend the new image $ps_preview_wrapper.prepend($newImage); var $tooltip_imgs = $ps_preview_wrapper.children(), tooltip_imgs_count = $tooltip_imgs.length; //if theres 2 images on the tooltip //animate the current one out, and the new one in if(tooltip_imgs_count > 1){ $tooltip_imgs.eq(tooltip_imgs_count-1) .stop() .animate({ left:-imageLeft+'px' },150,function(){ //remove the old one $(this).remove(); }); $tooltip_imgs.eq(0) .css('left',imageLeft + 'px') .stop() .animate({ left:'0px' },150); } } //if we are not using a "browser", we just show the tooltip, //otherwise we fade it // if(ie) $tooltip.css('left',left + 'px').show(); else $tooltip.stop() .animate({ left : left + 'px', opacity : 1 },150); } function hideTooltip(){ //hide / fade out the tooltip if(ie) $tooltip.hide(); else $tooltip.stop() .animate({ opacity : 0 },150); } function showImage(e){ var $link = $(this), idx = $link.index(), $image = $link.find('a').attr('href'), $currentImage = $ps_image_wrapper.find('img'), currentImageWidth = $currentImage.width(); //if we click the current one return if(current == idx) return false; //add class selected to the current page / dot $links.eq(current).removeClass('selected'); $link.addClass('selected'); //the new image element var $newImage = $('<img/>').css('left',currentImageWidth + 'px') .attr('src',$image); //if the wrapper has more than one image, remove oldest if($ps_image_wrapper.children().length > 1) $ps_image_wrapper.children(':last').remove(); //prepend the new image $ps_image_wrapper.prepend($newImage); //the new image width. //This will be the new width of the ps_image_wrapper var newImageWidth = $newImage.width(); //check animation direction if(current > idx){ $newImage.css('left',-newImageWidth + 'px'); currentImageWidth = -newImageWidth; } current = idx; //animate the new width of the ps_image_wrapper //(same like new image width) $ps_image_wrapper.stop().animate({ width : newImageWidth + 'px' },350); //animate the new image in $newImage.stop().animate({ left : '0px' },350); //animate the old image out $currentImage.stop().animate({ left : -currentImageWidth + 'px' },350); e.preventDefault(); } function nextImage() { var cache=''; cache = cache==''?current+':'+total_images:cache; if(current < total_images) $links.eq(current+1).trigger('click'); if(cache == (current+':'+total_images)) $links.eq(0).trigger('click'); } function prevImage(){ if(current > 0){ $links.eq(current-1).trigger('click'); } } setInterval( function(){ $('.ps_next').click(); },4000 ); Hey guys, So I got my autoscrolling javascript working, but I need to make it pause on mouseover. How do I accomplish that with my javascript code? Code: <script type="text/javascript"> var defaultStep=1; var step=defaultStep; var timer; function scrollDiv(id,s){ var obj=document.getElementById(id); var iScrollTop = obj.scrollTop; step=s||step; if (iScrollTop == 0){ step=defaultStep; } else if (obj.clientHeight + iScrollTop - obj.scrollHeight==0){ step=-defaultStep; } clearTimeout(timer); obj.scrollTop+=step; timer=setTimeout(function(){ scrollDiv(id); },100) } function stopMe(){ clearTimeout(timer); } function scrollMe(id){ scrollDiv(id) } </script> Thanks! I wrote a simple javescript for a slideshow that cycles through images and displays where the image is but I am wondering how to pause the slideshow and then add in a fading effect. Any help would be appreciated. index.html PHP Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Page 1</title> <link rel="stylesheet" type="text/css" href="css.css"></link> <script language="JavaScript" type="text/javascript" src="js.js"></script> </head> <body onLoad="LoadMenu(); PlaceArrow();"> <table border="0" cellspacing="0" cellpadding="0" id="hmt" summary="layout" align="center"> <tr><td colspan="4"><div id="htop"><img border="0" width="240" height="40" alt="" src="img/homet.png"></div></td></tr> <tr valign="top"> <td id="hmtgut"><img border="0" width="50" height="250" alt="" src="img/homel.png"></td> <td id="hmtl"><img border="0" width="280" height="270" src="img/homelogo.png"></td> <td id="hmtr"> <script language="JavaScript" type="text/javascript"> <!-- //preload images var image1=new Image() image1.src="photos/slides/photo01.jpg" var image2=new Image() image2.src="photos/slides/photo02.jpg" var image3=new Image() image3.src="photos/slides/photo03.jpg" var image4=new Image() image4.src="photos/slides/photo04.jpg" var image5=new Image() image5.src="photos/slides/photo05.jpg" var image6=new Image() image6.src="photos/slides/photo06.jpg" var image7=new Image() image7.src="img/thumbarrow.png" var image8=new Image() image8.src="img/spacer.gif" var cphoto = Math.ceil(6*Math.random()); document.write('<div id="homephoto"><a href="javascript:slidelink()"><img border="0" name="photo" width="230" height="230" src="photos/slides/photo0'+cphoto+'.jpg"></a></div>'); var step=cphoto var whichimage=step function slideit() { if (!document.images) return document.images.photo.src=eval("image"+step+".src") whichimage=step if (step<6) { step=parseInt(Math.ceil(6*Math.random())) } else { step=1 } setTimeout("slideit()",3000) var i = "a" + whichimage document.images.a1.src=eval("image8.src") document.images.a2.src=eval("image8.src") document.images.a3.src=eval("image8.src") document.images.a4.src=eval("image8.src") document.images.a5.src=eval("image8.src") document.images.a6.src=eval("image8.src") document.images[i].src=eval("image7.src") } slideit() function slidelink() { if (whichimage==1) window.open('img.php?img=1','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') else if (whichimage==2) window.open('img.php?img=2','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') else if (whichimage==3) window.open('img.php?img=3','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') else if (whichimage==4) window.open('img.php?img=4','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') else if (whichimage==5) window.open('img.php?img=5','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') else if (whichimage==6) window.open('img.php?img=6','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=400') } //--> </script> <noscript> <div id="homephoto"> <img border="0" name="photo" width="230" height="230" src="photos/slides/photo01.jpg"> </div> </noscript> </td> <td id="mtmenu" valign="middle">Links Here</td> </tr> <tr> <td colspan="4"> <div id="hfoot"> <div id="hbot"><img border="0" width="240" height="20" alt="" src="img/homeb.png"></div> <div id="thumb1"> <div><img border="0" vspace="9" hspace="2" name="a1" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(1); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo01thumb.jpg"></a></div> </div> <div id="thumb2"> <div><img border="0" vspace="9" hspace="2" name="a2" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(2); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo02thumb.jpg"></a></div> </div> <div id="thumb3"> <div><img border="0" vspace="9" hspace="2" name="a3" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(3); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo03thumb.jpg"></a></div> </div> <div id="thumb4"> <div><img border="0" vspace="9" hspace="2" name="a4" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(4); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo04thumb.jpg"></a></div> </div> <div id="thumb5"> <div><img border="0" vspace="9" hspace="2" name="a5" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(5); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo05thumb.jpg"></a></div> </div> <div id="thumb6"> <div><img border="0" vspace="9" hspace="2" name="a6" width="30" height="6" alt="" src="img/spacer.gif"></div> <div><a onClick="LoadPhoto(6); return false;"><img border="0" width="30" height="30" src="photos/thumbs/photo06thumb.jpg"></a></div> </div> </div> </td> </tr> </table> </table> </body> </html> js.js PHP Code: function PlaceArrow() { if ( cphoto ) { carrow = "a" + cphoto; document.images[carrow].src = "img/thumbarrow.png"; } } function LoadPhoto (i) { if (document.images) { carrow = "a" + cphoto; document.images[carrow].src = "img/spacer.gif"; narrow = "a" + i; nphoto = "photo0" + i; document.images[narrow].src = "img/thumbarrow.png"; document.images['photo'].src = "photos/slides/" + nphoto + ".jpg"; cphoto = i; } } Hello everyone, 1.) I'm not a programmer beyond HTML, CSS and only a basic knowledge of javascript, it doesn't take much for me to get lost beyond my skills in javascript. 2.) Is someone willing to add and explain the changes to the code below to include a pause on mouseover? Code: var currentSlide = 1; var maxSlides = 0; function fadeImage(){ opacity = 100; if(steps < 4){ steps += 1; opacity = opacity / steps; imageObj = document.getElementById("slide-"+currentSlide); imageObjN = document.getElementById("slide-"+nextSlide); imageObjN.style.display = "block"; imageObj.style.opacity = "" + opacity / 100; imageObjN.style.opacity = "" + ((steps * 25) / 100); //fade slideTimeout = setTimeout("fadeImage()", 170); /** fade transition speed */ }else{ steps = 1; document.getElementById("slide-"+currentSlide).style.display = "none"; currentSlide += 1; if(currentSlide > maxSlides){ currentSlide = 1; } showSlide(); } } function initSlideshow(){ slidesCollection = document.getElementById("slides").children; maxSlides = slidesCollection.length; for (var i=0; i < maxSlides; i++){ slidesCollection[i].id = "slide-"+(i+1); if (i > 0) slidesCollection[i].style.display = "none"; } steps = 1; nextSlide = 2; slideTimeout = 0; showSlide(); } function showSlide(){ clearTimeout(slideTimeout); nextSlide = currentSlide + 1; if (currentSlide >= maxSlides){ nextSlide = 1; } slideTimeout = setTimeout("fadeImage()", 8300); /** display time of slide */ } Hello! I was looking for a way to pause animated gifs per command, and I found a thread in this forum with the appropriate instruction: http://www.codingforums.com/showthread.php?t=177543 I used the code example from there and adjusted it to my needs on my website: http://www.baelavay.com/v6 The code works as it should! (The button is in the top-left corner) But there are 2 things I would want to improve. Unfortunately I can't fix them myself, maybe you can help 1) I don't want to use a button for pausing the gifs. Instead, I want the gifs to pause when Code: <img id="tiles-img" ...> is clicked. So what I tried is to replace the line Code: obj=document.getElementById('button'); with Code: obj=document.getElementById('tiles-img'); But then, it doesn't work anymore. Why? 2) (*edit: RESOLVED) The button only starts working from the 2nd click on? (No gif pausing at 1st click) Thank you in advance. 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> Hi everyone! I'm using a jquery image sliding plugin from this site: http://flexidev.co.za/projects/flexislider/ It scrolls smoothly and continuously which is great. But I'm wanting to add a "click to pause" feature to it, so when you click any of the images the whole thing pauses, and when you click again it restarts. I'm not great with javascript though and I can't figure out how to do that, if it's even possible. I'd really appreciate any pointers or tips! Here is the javascript: Code: var speed = 50; var pic, numImgs, arrLeft, i, totalWidth, n, myInterval; $(window).load(function(){ pic = $("#slider").children("img"); numImgs = pic.length; arrLeft = new Array(numImgs); for (i=0;i<numImgs;i++){ totalWidth=0; for(n=0;n<i;n++){ totalWidth += $(pic[n]).width(); } arrLeft[i] = totalWidth; $(pic[i]).css("left",totalWidth); } myInterval = setInterval("flexiScroll()",speed); $('#imageloader').hide(); $(pic).show(); }); function flexiScroll(){ for (i=0;i<numImgs;i++){ arrLeft[i] -= 1; if (arrLeft[i] == -($(pic[i]).width())){ totalWidth = 0; for (n=0;n<numImgs;n++){ if (n!=i){ totalWidth += $(pic[n]).width(); } } arrLeft[i] = totalWidth; } $(pic[i]).css("left",arrLeft[i]); } } I have the following script in my page Code: var tickspeed=4000 var enablesubject=0 if (document.getElementById){ document.write('<style type="text/css">\n') document.write('.dropcontent{display:none;}\n') document.write('</style>\n') } var firstDiv=0 var allDivs=0 function contractall(){ var inc=0 while (document.getElementById("dropmsg"+inc)){ document.getElementById("dropmsg"+inc).style.display="none" inc++ } } function expandone(){ var firstDivObj=document.getElementById("dropmsg"+firstDiv) contractall() document.getElementById("dropcontentsubject").innerHTML=firstDivObj.getAttribute("subject") firstDivObj.style.display="block" firstDiv=(firstDiv<allDivs-1)? firstDiv+1 : 0 setTimeout("expandone()",tickspeed) } function startscroller(){ while (document.getElementById("dropmsg"+allDivs)!=null) allDivs++ expandone() if (!enablesubject) document.getElementById("dropcontentsubject").style.display="none" } if (window.addEventListener) window.addEventListener("load", startscroller, false) else if (window.attachEvent) window.attachEvent("onload", startscroller) I also have the following in my html: Code: <div id="dropcontentsubject"></div> <div id="dropmsg0" class="dropcontent" subject=""></div> There are a total of 4 dropmsg# divs. I need to be able to input 4 navigation buttons below this code that will, when clicked, pause the ticker and go directly to the "dropmsg#" assigned to that button. I would deeply appreciate any assistance with this. Thank you. i have a photo slideshow that loads in the header so when the page is loaded the slide show is there on the left. it looks like this (page layout) header --------------------> slideshow content ---------------------> image footer ----------------------- where it says image i am adding an image, that colum is controlled by the header so i added a div in there for the image. what is happening is that since the image is small and the slideshow is large, when the page loads the single image pops up for a second where the slide show is, then it moves down on the page where it should be. I know this is caused by the fact that the image loads faster than the slideshow so we see the image first in that space. what i am trying to do is pause the single image load until the slideshow loads, but i dont know how? I cant move the image down and load it in the body because that left side column is controlled by the header slideshow it has to be part of it when it loads. has to be a way to make the slide show load on the page and then the image. here is the setup on the header.. Code: <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%"> <tr><td height="10px"> </td></tr> <tr><td valign="top"> <?php if($_SERVER['PHP_SELF']!='/crop.php') {?> <div style="width:250px; background-color:#666666; height:250px; float:right; display:inline; color:#CCCCCC; margin-right:8px;"> <div id="fadeshow1"> </div> <!-- close fadeshow div --> <!-- added image --> <div style="text-align:center;width:250px;padding-top:30px; background-color:#FFFFFF;float:right;color:#000000;"> <img src="<?=$SKIN_IMAGE_PATH?>/myimage.gif" border="0" alt="" title="myimage" /> </div> <!-- end add --> </div> <!-- close top div for fadeshow and this image --> <?php } ?> the body of the site pages load here I have a rotating content js, and I want to add a pause to it when its mosed over, heres the current code: Code: <body> <a id="imageurl" ><img id="Rotating1" border="0"></img></a> <script language="JavaScript"> function RotateImages(Start) { var a = new Array("image1","image2","image3","image4"); var c = new Array("www.google.ca", "www.google.ca", "www.google.ca", "www.google.ca"); 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) + ")",3000); } RotateImages(0); </script> </body> Hi all and hope that you can help. I have an image slideshow that works fine and, I may be being over ambitious but I'd like to combine the Play and Pause buttons so that when the slideshow is playing, the Play button is replaced by the Pause button and when it is paused the Pause button is replaced by the Play button. Sounds like a simple JavaScipt change image function but both buttons have roll over effects and they both have different JavaScript functions assigned to them so I'm struggling to get my head around what I need to do. Thanks for your interest, R I've highlighted the relevant chunks of code below... The HTML / CSS... Code: <style type="text/css"> #midcol { padding: 0 25px; width: 672px; margin-left:auto; margin-right:auto; text-align:center; } #first {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/first.gif) no-repeat 0 0; } #previous {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/previous.gif) no-repeat 0 0; } #pause {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/pause.gif) no-repeat 0 0; } #pplay {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/play.gif) no-repeat 0 0; } #next {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/next.gif) no-repeat 0 0; } #last {height:32px; width:32px; text-indent:-9999px; overflow:hidden; display:inline-block; border:0; background:url(navbars/last.gif) no-repeat 0 0; } #first:hover {background:url(navbars/first.gif) no-repeat 0 -32px; } #previous:hover {background:url(navbars/previous.gif) no-repeat 0 -32px;} #pause:hover {background:url(navbars/pause.gif) no-repeat 0 -32px;} #pplay:hover {background:url(navbars/play.gif) no-repeat 0 -32px;} #next:hover {background:url(navbars/next.gif) no-repeat 0 -32px;} #last:hover {background:url(navbars/last.gif) no-repeat 0 -32px;} </style> </head> <body> <div id="midcol"> <table width="592" border="0"> <tr > <td colspan="8" height="450"><img id="myImage" name="myImage" src="images/large/1.jpg"></img></td></tr> <tr><td colspan="8"><br /></td></tr> <tr height="60"><td colspan="8" id="caption">Auto play will start when all the images have loaded...</td></tr> <tr height="33"> <td width="160"></td> <td id="first" onclick="first();clearTimeout(timerID);"></td> <td id="previous" onclick="previous();clearTimeout(timerID);"></td> <td id="pause" onclick="clearTimeout(timerID);"></td> <td id="pplay" onclick="swapPicture();"></td> <td id="next" onclick="next();clearTimeout(timerID);"></td> <td id="last" onclick="last();clearTimeout(timerID);"></td> <td width="160"><form name="dropdown" action="">Slide duration: <select id="duration" onchange="setInterval(this.form.duration);"> <option value="1">1</option> <option value="2">2</option> <option value="3" selected="selected">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </form></td> </tr> </table> The JavaScript... Code: var dimages=new Array(); var numImages=31; var interval = 3000; var image_dir = "images/large/" for (i=0; i<numImages; i++) { dimages[i]=new Image(); dimages[i].src=image_dir+(i+1)+".jpg"; } var imageCaption = new Array(); var ImageNum = 0; imageCaption[ImageNum++] = "Caption 1."; imageCaption[ImageNum++] = "Caption 2."; etc. etc. var curImage=-1; function swapPicture() { if (document.images) // does the browser support image changes? { var nextImage=curImage+1; if (nextImage>=numImages) nextImage=0; if (dimages[nextImage] && dimages[nextImage].complete) // has the next image been fully loaded? { var target=0; if (document.images.myImage) target=document.images.myImage; cap = imageCaption[nextImage]; document.getElementById('caption').innerHTML=cap; if (document.all && document.getElementById("myImage")) target=document.getElementById("myImage"); cap = imageCaption[nextImage]; document.getElementById('caption').innerHTML=cap; // make sure target is valid. It might not be valid // if the page has not finished loading if (target) { target.src=dimages[nextImage].src; curImage=nextImage; } doTimer(interval); } else { setTimeout("swapPicture()", 500); // if not fully loaded, wait 500ms then try again. } } } function first(){ // Goes to the 1st image and stops curImage=-1; stopTimer(); swapPicture(); } function last(){ // Goes to the last image and stops curImage=numImages-2; stopTimer(); swapPicture(); } function previous(){ // Goes to the previous image and stops curImage=curImage-2; stopTimer(); swapPicture(); } function next(){ // Goes to the next image and stops stopTimer(); swapPicture(); } function doTimer(interval){ // The Play button timerID=setTimeout("swapPicture()",interval); } function stopTimer(){ // The Pause button clearTimeout(timerID); } function setInterval(t){ // The slide duration drop down box. var e = document.getElementById("duration"); interval = (e.options[e.selectedIndex].value)*1000; } doTimer(interval); // Starts the slideshow on load. Hello, I just have a quick question; what code would I need to insert into the coding below in order to get the slide show to pause when someone hovers their cursor on an image? Code: <html> <head> <script type="text/javascript"> <!-- //preload images var image1=new Image() image1.src="firstcar.gif" var image2=new Image() image2.src="secondcar" var image3=new Image() image3.src="thirdcar.gif" //--> </script> </head> <body> <a href="javascript:slidelink()"> <img src="firstcar.gif" name="slide" border="0" width="100" height="56" /></a> <script type="text/javascript"> <!-- var step=1 var whichimage=1 function slideit(){ if (!document.images) return document.images.slide.src=eval("image"+step+".src") whichimage=step if (step<3) step++ else step=1 setTimeout("slideit()",1800) } slideit() function slidelink(){ if (whichimage==1) window.location="link1.htm" else if (whichimage==2) window.location="link2.htm" else if (whichimage==3) window.location="link3.htm" } //--> </script> </body> </html> Thanks in advance! I'm newer to coding this stuff and have tried various ways to get this to work, ending in failure of course. Hi there, This forum was linked off of http://www.javascriptkit.com so I was hoping someone could lend me a hand. I like the image rotator script at http://www.javascriptkit.com/script/...tionshow.shtml as it is very easy to use. It currently pauses the image rotation on mouseover, but I would like to enable it to also pause onFocus and onBlur. My initial thoughts were to add a small "pause" form button under the image description that people could tab to with the keyboard, and perhaps capture the onBlur or onFocus event to initiate the pause. But the code is difficult to wrap my mind around. Any thoughts? Link to .js code: http://www.javascriptkit.com/script/...nsitionshow.js Hello Every 1 . how do i put the below Code on A Marquee ... PHP Code: echo "<td>$name</td>"; echo "<td align='right'><font color=$font_color>$comment</font></td>"; echo "<td align='right'>$date</td>"; I've got a code. I've listed it below. The only question I have which I am sure I'm just overlooking it, but I need to find a way to squeeze this to the top of the screen and to the left. Where can I modify this on this code? The first section is the whole file. Thanks! Edit: I'm trying to remove the awkward gap on top and to the left. I merged the .js file since this will only be a file that is updated with new news. Code: <html> <head> <script type="text/javascript"> /* Text and/or Image Crawler Script v1.5 (c)2009-2011 John Davenport Scheuer as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1 - This Notice Must Remain for Legal Use updated: 4/2011 for random order option, more (see below) */ /* Update 4/2011 to v1.5 - Adds optional random property. Set it to true to use. Fixes browser crash from empty crawlers, ad and image blocking software/routines. Fixes behavior in some IE of breaking script if an image is missing. Adds alt attributes to images without them to aid in diagnosis of missing/corrupt images. This may be disabled with the new optional noAddedAlt property set to true. Internal workings enhanced for greater speed of execution, less memory usage. */ ///////////////// No Need to Edit - Configuration is Done in the On Page Call(s) ///////////////// function marqueeInit(config){ if(!document.createElement) return; marqueeInit.ar.push(config); marqueeInit.run(config.uniqueid); } (function(){ if(!document.createElement) return; marqueeInit.ar = []; document.write('<style type="text/css">.marquee{white-space:nowrap;overflow:hidden;visibility:hidden;}' + '#marq_kill_marg_bord{border:none!important;margin:0!important;}<\/style>'); var c = 0, tTRE = [/^\s*$/, /^\s*/, /\s*$/, /[^\/]+$/], req1 = {'position': 'relative', 'overflow': 'hidden'}, defaultconfig = { style: { //default style object for marquee containers without configured style 'margin': '0 auto' }, direction: 'left', inc: 2, //default speed - pixel increment for each iteration of a marquee's movement mouse: 'pause' //default mouseover behavior ('pause' 'cursor driven' or false) }, dash, ie = false, oldie = 0, ie5 = false, iever = 0; /*@cc_on @*/ /*@if(@_jscript_version >= 5) ie = true; try{document.documentMode = 2000}catch(e){}; iever = Math.min(document.documentMode, navigator.appVersion.replace(/^.*MSIE (\d+\.\d+).*$/, '$1')); if(iever < 6) oldie = 1; if(iever < 5.5){ Array.prototype.push = function(el){this[this.length] = el;}; ie5 = true; dash = /(-(.))/; String.prototype.encamel = function(s, m){ s = this; while((m = dash.exec(s))) s = s.replace(m[1], m[2].toUpperCase()); return s; }; } @end @*/ if(!ie5){ dash = /-(.)/g; function toHump(a, b){return b.toUpperCase();}; String.prototype.encamel = function(){return this.replace(dash, toHump);}; } if(ie && iever < 8){ marqueeInit.table = []; window.attachEvent('onload', function(){ marqueeInit.OK = true; for(var i = 0; i < marqueeInit.table.length; ++i) marqueeInit.run(marqueeInit.table[i]); }); } function intable(el){ while((el = el.parentNode)) if(el.tagName && el.tagName.toLowerCase() === 'table') return true; return false; }; marqueeInit.run = function(id){ if(ie && !marqueeInit.OK && iever < 8 && intable(document.getElementById(id))){ marqueeInit.table.push(id); return; } if(!document.getElementById(id)) setTimeout(function(){marqueeInit.run(id);}, 300); else new Marq(c++, document.getElementById(id)); } function trimTags(tag){ var r = [], i = 0, e; while((e = tag.firstChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); while((e = tag.lastChild) && e.nodeType === 3 && tTRE[0].test(e.nodeValue)) tag.removeChild(e); if((e = tag.firstChild) && e.nodeType === 3) e.nodeValue = e.nodeValue.replace(tTRE[1], ''); if((e = tag.lastChild) && e.nodeType === 3) e.nodeValue = e.nodeValue.replace(tTRE[2], ''); while((e = tag.firstChild)) r[i++] = tag.removeChild(e); return r; } function randthem(tag){ var els = oldie? tag.all : tag.getElementsByTagName('*'), i = els.length - 1, childels = [], newels = []; for (i; i > -1; --i){ if(els[i].parentNode === tag){ childels.push(els[i]); newels.push(els[i].cloneNode(true)); } } newels.sort(function(){return 0.5 - Math.random();}); i = childels.length - 1; for (i; i > -1; --i){ tag.replaceChild(newels[i], childels[i]); } } function Marq(c, tag){ var p, u, s, a, ims, ic, i, marqContent, cObj = this; this.mq = marqueeInit.ar[c]; if(this.mq.random){ randthem(tag); } for (p in defaultconfig) if((this.mq.hasOwnProperty && !this.mq.hasOwnProperty(p)) || (!this.mq.hasOwnProperty && !this.mq[p])) this.mq[p] = defaultconfig[p]; this.mq.style.width = !this.mq.style.width || isNaN(parseInt(this.mq.style.width))? '100%' : this.mq.style.width; if(!tag.getElementsByTagName('img')[0]) this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? tag.offsetHeight + 3 + 'px' : this.mq.style.height; else this.mq.style.height = !this.mq.style.height || isNaN(parseInt(this.mq.style.height))? 'auto' : this.mq.style.height; u = this.mq.style.width.split(/\d/); this.cw = this.mq.style.width? [parseInt(this.mq.style.width), u[u.length - 1]] : ['a']; marqContent = trimTags(tag); tag.className = tag.id = ''; tag.removeAttribute('class', 0); tag.removeAttribute('id', 0); if(ie) tag.removeAttribute('className', 0); tag.appendChild(tag.cloneNode(false)); tag.className = ['marquee', c].join(''); tag.style.overflow = 'hidden'; this.c = tag.firstChild; this.c.appendChild(this.c.cloneNode(false)); this.c.style.visibility = 'hidden'; a = [[req1, this.c.style], [this.mq.style, this.c.style]]; for (i = a.length - 1; i > -1; --i) for (p in a[i][0]) if((a[i][0].hasOwnProperty && a[i][0].hasOwnProperty(p)) || (!a[i][0].hasOwnProperty)) a[i][1][p.encamel()] = a[i][0][p]; this.m = this.c.firstChild; if(this.mq.mouse === 'pause'){ this.c.onmouseover = function(){cObj.mq.stopped = true;}; this.c.onmouseout = function(){cObj.mq.stopped = false;}; } this.m.style.position = 'absolute'; this.m.style.left = '-10000000px'; this.m.style.whiteSpace = 'nowrap'; if(ie5) this.c.firstChild.appendChild((this.m = document.createElement('nobr'))); if(!this.mq.noAddedSpace) this.m.appendChild(document.createTextNode('\xa0')); for(i = 0; marqContent[i]; ++i) this.m.appendChild(marqContent[i]); if(ie5) this.m = this.c.firstChild; ims = this.m.getElementsByTagName('img'); if(ims.length){ for(ic = 0, i = 0; i < ims.length; ++i){ ims[i].style.display = 'inline'; if(!ims[i].alt && !this.mq.noAddedAlt){ ims[i].alt = (tTRE[3].exec(ims[i].src)) || ('Image #' + [i + 1]); if(!ims[i].title){ims[i].title = '';} } ims[i].style.display = 'inline'; ims[i].style.verticalAlign = ims[i].style.verticalAlign || 'top'; if(typeof ims[i].complete === 'boolean' && ims[i].complete) ic++; else { ims[i].onload = ims[i].onerror = function(){ if(++ic === ims.length) cObj.setup(c); }; } if(ic === ims.length) this.setup(c); } } else this.setup(c) } Marq.prototype.setup = function(c){ if(this.mq.setup) return; this.mq.setup = this; var s, w, cObj = this, exit = 10000; if(this.c.style.height === 'auto') this.c.style.height = this.m.offsetHeight + 4 + 'px'; this.c.appendChild(this.m.cloneNode(true)); this.m = [this.m, this.m.nextSibling]; if(this.mq.mouse === 'cursor driven'){ this.r = this.mq.neutral || 16; this.sinc = this.mq.inc; this.c.onmousemove = function(e){cObj.mq.stopped = false; cObj.directspeed(e)}; if(this.mq.moveatleast){ this.mq.inc = this.mq.moveatleast; if(this.mq.savedirection){ if(this.mq.savedirection === 'reverse'){ this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.direction === 'right'? 'left' : 'right';}; } else { this.mq.savedirection = this.mq.direction; this.c.onmouseout = function(e){ if(cObj.contains(e)) return; cObj.mq.inc = cObj.mq.moveatleast; cObj.mq.direction = cObj.mq.savedirection;}; } } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.mq.inc = cObj.mq.moveatleast;}; } else this.c.onmouseout = function(e){if(!cObj.contains(e)) cObj.slowdeath();}; } this.w = this.m[0].offsetWidth; this.m[0].style.left = 0; this.c.id = 'marq_kill_marg_bord'; this.m[0].style.top = this.m[1].style.top = Math.floor((this.c.offsetHeight - this.m[0].offsetHeight) / 2 - oldie) + 'px'; this.c.id = ''; this.c.removeAttribute('id', 0); this.m[1].style.left = this.w + 'px'; s = this.mq.moveatleast? Math.max(this.mq.moveatleast, this.sinc) : (this.sinc || this.mq.inc); while(this.c.offsetWidth > this.w - s && --exit){ w = isNaN(this.cw[0])? this.w - s : --this.cw[0]; if(w < 1 || this.w < Math.max(1, s)){break;} this.c.style.width = isNaN(this.cw[0])? this.w - s + 'px' : --this.cw[0] + this.cw[1]; } this.c.style.visibility = 'visible'; this.runit(); } Marq.prototype.slowdeath = function(){ var cObj = this; if(this.mq.inc){ this.mq.inc -= 1; this.timer = setTimeout(function(){cObj.slowdeath();}, 100); } } Marq.prototype.runit = function(){ var cObj = this, d = this.mq.direction === 'right'? 1 : -1; if(this.mq.stopped || this.mq.stopMarquee){ setTimeout(function(){cObj.runit();}, 300); return; } if(this.mq.mouse != 'cursor driven') this.mq.inc = Math.max(1, this.mq.inc); if(d * parseInt(this.m[0].style.left) >= this.w) this.m[0].style.left = parseInt(this.m[1].style.left) - d * this.w + 'px'; if(d * parseInt(this.m[1].style.left) >= this.w) this.m[1].style.left = parseInt(this.m[0].style.left) - d * this.w + 'px'; this.m[0].style.left = parseInt(this.m[0].style.left) + d * this.mq.inc + 'px'; this.m[1].style.left = parseInt(this.m[1].style.left) + d * this.mq.inc + 'px'; setTimeout(function(){cObj.runit();}, 30 + (this.mq.addDelay || 0)); } Marq.prototype.directspeed = function(e){ e = e || window.event; if(this.timer) clearTimeout(this.timer); var c = this.c, w = c.offsetWidth, l = c.offsetLeft, mp = (typeof e.pageX === 'number'? e.pageX : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft) - l, lb = (w - this.r) / 2, rb = (w + this.r) / 2; while((c = c.offsetParent)) mp -= c.offsetLeft; this.mq.direction = mp > rb? 'left' : 'right'; this.mq.inc = Math.round((mp > rb? (mp - rb) : mp < lb? (lb - mp) : 0) / lb * this.sinc); } Marq.prototype.contains = function(e){ if(e && e.relatedTarget){var c = e.relatedTarget; if(c === this.c) return true; while ((c = c.parentNode)) if(c === this.c) return true;} return false; } function resize(){ for(var s, w, m, i = 0; i < marqueeInit.ar.length; ++i){ if(marqueeInit.ar[i] && marqueeInit.ar[i].setup){ m = marqueeInit.ar[i].setup; s = m.mq.moveatleast? Math.max(m.mq.moveatleast, m.sinc) : (m.sinc || m.mq.inc); m.c.style.width = m.mq.style.width; m.cw[0] = m.cw.length > 1? parseInt(m.mq.style.width) : 'a'; while(m.c.offsetWidth > m.w - s){ w = isNaN(m.cw[0])? m.w - s : --m.cw[0]; if(w < 1){break;} m.c.style.width = isNaN(m.cw[0])? m.w - s + 'px' : --m.cw[0] + m.cw[1]; } } } } if (window.addEventListener) window.addEventListener('resize', resize, false); else if (window.attachEvent) window.attachEvent('onresize', resize); })(); /* Text and/or Image Crawler Script v1.5 (c)2009-2011 John Davenport Scheuer as first seen in http://www.dynamicdrive.com/forums/ username: jscheuer1 - This Notice Must Remain for Legal Use updated: 4/2011 for random order option, more (see below) */ </script> </head> <body> <font color="white" face="arial" size="2" background="#0066CC"> <div class="marquee" id="mycrawler" align="left"> 2/21/12 Today is testing the marquee. This will be used for announcements. Stay tuned!!!                         </div></font> <script type="text/javascript"> marqueeInit({ uniqueid: 'mycrawler', style: { 'padding': '1px', 'width': '1000px', //change to 1000 for normal, change to 0 for off 'background': '#0066CC', 'border': '0px solid black' }, inc: 1, //speed - pixel increment for each iteration of this marquee's movement mouse: 'false', //mouseover behavior ('pause' 'cursor driven' or false) moveatleast: 1, neutral: 150, savedirection: true }); </script> </body> </html> I'm looking for a code like these news tickers you see on TVS nowadays at the bottom of the screen, where they show you the latest headlines. I want a simple scrolling marquee text that shows the text based on a txt file with the ability to insert an image between every line |