JavaScript - Slideshow Timings (newbie Question)
Hi
I'm trying to get a slideshow working but the timings are all over the place. I can make it loop through once, neatly, but thereafter the timings seem to out - I have a loop set up to run five times. I think this is because the function is incrementing the delay values or something along those lines (I know there's a neater way to write this but I'm just starting out). Code: function slideWinder () { var x = 1 for (var x = 1; x < 5; x++) { $('#slideone').delay(0).fadeIn(0).delay(2000).fadeOut(400); $('#slidetwo').delay(2000).fadeIn(400).delay(2000).fadeOut(400); $('#slidethree').delay(4000).fadeIn(400).delay(2000).fadeOut(400); $('#slidefour').delay(6000).fadeIn(400).delay(2000).fadeOut(400); $('#slidefive').delay(8000).fadeIn(400).delay(2000).fadeOut(400); $('#slidesix').delay(10000).fadeIn(400).delay(2000).fadeOut(400); } } Similar Tutorialshi, please ignore this thread..it is a duplicate of one already active. MODS please delete. apologies for my mistake. Hi, Im a complete newbie to javascript and I've basically copied and pasted the javascript I found here to use on my site. Its an onMouseOver slideshow: http://www.javascriptkit.com/script/...ifferent.shtml to use on my site. Basically, my problem is how do I add a second, separate image in a different location on the web page, associated with this script? If I post <a href="javascript:warp()"><img src="myimage" name="targetimage" border=0></a> in two different locations, which is the script for the image, the script stops working, but having it once makes it work. So how do I add two different image locations? Can someone please help me here? I just want to add more images in a different location. ie have image location 1, and image location 2. Thanks in advance Script Below: Code: <script> function changeimage(towhat,url){ if (document.images){ document.images.targetimage.src=towhat.src gotolink=url } } function warp(){ window.location=gotolink1 } </script> <script language="JavaScript1.1"> var myimages=new Array() var gotolink="#" function preloadimages(){ for (i=0;i<preloadimages.arguments.length;i++){ myimages[i]=new Image() myimages[i].src=preloadimages.arguments[i] } } preloadimages(my images here) </script> For the Links: <a href="creativewriting.html" onMouseover="changeimage(myimages[1],this.href)">Creative Writing</a><br> For the Image: <a href="javascript:warp()"><img src="myimage" name="targetimage" border=0></a> I have been searching through the forums and have not been able to find exactly what I am looking for. I built my web site a while back using Flash. Right now I am trying to convert it to a non-Flash site. I am trying to duplicate my slideshow, with a caption, and forward/back button in javascript. If anyone can offer advice on how to do this I would greatly appreciate it. my current flash site: http://moparch.com/moparch/architecture/msbe/msbe.html Thanks in advance. P.S. I am brand new to javascript. My experience is limited to the few online tutorials that I have worked through. I was planning on using Dreamweaver (which I am already familiar with) to assemble the final site once I get the necessary javascript figured out. Hi everyone, I am a newbie Javascript programmer. I have gotten better lately and am starting creating scripts from scratch to test my knowledge. I wrote the script below and needless to say, it does not work... yet. I know I am not far and I need someone's help to tweak my script and let me know what was wrong with. That would be greatly appreciated. Anyone? I have this div in the middle of a page which has an image. I want the image.src to switch to the next image every 3 seconds. Here's my html code: Code: <body> <div id="slideShow"> <img src="pic3.jpg" id="image" /> </div> </body> Here's my js code: Code: window.onload = initLoad; function initLoad() { // Create a new image object oImage = new Image; // tie the object image object with your target id in your html code oImage = document.getElementById("image"); //Create a new date object var oCurrDate = new Date(); // Create a new time object var oCurrentTime = oCurrDate.getSeconds(); //Loop through all images in the document for(var i=0; i<document.images.length; i++) { //the current image remains so as long as 3 seconds or less have passed while(oCurrentTime <= oCurrentTime + 3) { // if 3 seconds have not passed, your current picture remains on the screen oImage.src = document.images[i].src; } } } Was wondering if someone could help me quickly, i'm have a strange issue with a slideshow i have built in javascript. The slideshow works fine until you add any other image onto the page like a banner or anything. As soon as you do that when you click next on the slideshow that image or banner with change to the next picture instead of the desired image if that makes any sense... Would appreciate any help, thank you! here is the link to my practice website, so you can see what is going on pretty new to all of this.. http://dpetersen.net46.net/advancedw...l.html?agree=0 Is there a way to have the websites open in new windows? I've tried the standard ways, but script doesn't work when I change it. Does anyone know what and where in the script I can add for opening in new windows. Thank you The script is shown on this page: http://www.javascriptkit.com/script/cut181.shtml Hey guys, this should be a very easy fix for someone who knows Javascript (which I don't). The following code allows the class "ul.slideshow-nav li" to control the navigation of the slideshow, I want to adjust this script to allow "ul.slideshow-nav li" AND "ul.slideshow-nav2 li" to do this, possible? Code: $slideshow = { context: false, tabs: false, timeout: 8000, fx: 'scrollLeft', slideSpeed: 900, tabSpeed: 900, init: function() { this.context = $('#content-slideshow'); this.tabs = $('ul.slideshow-nav li', this.context); this.tabs.remove(); this.startSlideshow(); }, startSlideshow: function() { $('div.slideshow > ul', $slideshow.context).cycle({ fx: $slideshow.fx, pager: $('ul.slideshow-nav', $slideshow.context), pagerAnchorBuilder: $slideshow.startTabs, befo $slideshow.Tabactive, timeout: $slideshow.timeout, speed: $slideshow.slideSpeed, fastOnEvent: $slideshow.tabSpeed, pauseOnPagerHover: true, pause: true }); }, startTabs: function(i, slide) { return $slideshow.tabs.eq(i); }, Tabactive: function(currentSlide, nextSlide) { var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context); if(activeTab.length) { $slideshow.tabs.removeClass('on'); activeTab.parent().addClass('on'); } } }; $(function() { $slideshow.init(); }); Thinking in Objects 4 objects w/constructors/overloads min 3 properties on each min 3 methods total was just wondering if anyone had any good links or tutorials to get me started on my first javascript assignment Hi! Im new to the world of javascript, so bare with me. It might be a stupid question but i got a input form, i know how to get the data in but i need to single out one of the numbers. the input looks like: xxxxxx-xxxx I've tried almost everything that i can think of... A nudge in the right direction would be appreciated. This is what I am aiming for. I want to be able to click on a word that would then write text in a specified area. This is what I came up with but it writes it at the top of the page and only for a moment then disappears.... These are my clickable words Code: <a href="#textarea" onClick="MathHomework('W2')">Week 2</a> <a href="#textarea" onClick="MathHomework('W3')">Week 3</a> the anchor named 'textarea' is where I want the output to be written which is placed on my html page. This is my newbie script Code: <script type="text/javascript"> function MathHomework(week) { if (week == "W2") document.write("<p>Review Chapter Twelve</p>"); else if (week == "W3") document.write("<p>Final Chapter Review Test</p>"); } </script> <a name="textarea"> (text area for javascript output)</a> so is my onclick syntax wrong maybe? and yes I have read rule#5 and I am trying to understand my mistakes. Thank you in advance I'm in a computer coding class, and I'm having a bit of trouble with Javascript. I'm not looking for anyone to do my homework for me, but any hints you could give me as to why this code isn't working would be greatly appreciated. Basically, I need an empty text box where the user enters their guess as to my age. The user enters their guess, and then gets an answer as to whether their guess is right, too high, or too low. The page looks right, but I can't get the function to work. Thank you... <html> <head> <script> function howoldami(age) if(age=23) { alert("You guessed right!"); } else if { (age>23) alert("I'm not that old."); } else { alert("I'm not that young."); } </script> </head> <body> <form> Guess My Age!<input name="age"><br> <input type=button value=Guess! onclick="howoldami(age.value)"> </form> </body> </html> Hello, I'm in the process of getting a better understanding of javascript (instead of just copying and pasting JQuery script onto my site). So I have a(dumb?) question. Can I name a var what ever I want? For example, var car_name("Ford Escape"); Or am I misunderstanding this? THanks. Hi Everyone I'm learning Javascript with varying degree's of success but am very much in the early phase. My question/problem is this: [ICODE]<!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>Untitled Document</title> </head> <body> <script language="javascript" type="text/javascript"> var degFahren = new Array(212, "string data", -459.67); var degCent = new Array(); var loopCounter; for(loopcounter =0; loopCounter <= 2; loopCounter++){ if(isNaN(degFahren[loopCounter])){ alert("Data " + degFahren[loopCounter] + " at array index " + loopCounter + " is invalid"); continue; } degcent[loopCounter] = 5/9 * (degFahren[loopCounter] -32); } for (loopCounter =2; loopCounter >=0; loopCounter --){ document.write("Value " + loopCounter + " was " + degFahren[loopCounter] + " degrees Fahrenheit"); document.write(" which is " + degCent[loopCounter] + " degrees centigrade<br />"); } </script> </body> </html> /ICODE] The following code does not return any errors in my browser but I'm confused since I'm sure I should be seeing an alert box telling me that there is invalid data entered bu this doesn't happen, also as far as I can make out I should only be receiving an error for the 2nd loop but there seem to be an error message returned for all 3 loops?? This is all possibly correct but I'm learning from a book and I have no-one to ask these mundane questions to. Any help would be greatly received. Sara I have yet to have my ah-ha moment with Javascript but I think its coming soon. there are small things that seem to be baffling me and Im hoping posting to the forums to get help from people of limitless wisdom. What exactly does the "|" mean in this code? or I should say what does it do? Code: document.template.Aprod_string.value = document.template.Aprod_string.value + "|" + string_recode(Aprod_array) ; I've had several problems with document.getElementById() and haven't been able to find a reason for this. I've searched these forums and I'm sorry if I've still managed to miss if there's an answer to this, as it seems to me to be a basic question. When I use getElementById() it keeps returning as 'undefined' in both FF och IE. I've had to use getElementsByName() instead, and since I only have one element, I have to write element[0] to make it work which seems rather redundant. This is parts of my JS code: Code: var postName = document.getElementsByName("postName"); //getElementById doesn't work here var postText = document.getElementsByName("postText"); //...nor here. if (postName[0].value == "" && postText[0].value == "") { document.getElementById('feedback').innerHTML = "Some text."; //For some stupid reason getElementById works here! } And the HTML looks somewhat like this: Code: <div class="addName" id="addName"> <input type="text" name="postName" id="postName" class="textBox"></input> </div> <div class="addText" id="addText"> <textarea class="textarea" name="post" id="postText"></textarea> </div> <div class="feedback" id="feedback"></div> I don't see why it wouldn't work, but this isn't the only time it's happened so I must be missing something. Anyone who can enlighten me as to what that is? Hi, I am just beginning out with Javascript and trying to complete a simple login page. Clicking on the Login button should bring up a message 'Access authorised' or 'Access denied' in the 'output' div of the page. Unfortunately only 'Access Denied' displays, even if the password entered is correct. There are no messages displayed in the Error Console. Any advice greatly appreciated! Code: <html> <head> <title>Function Example</title> <script language="javascript" type="text/javascript"> function isAccessAuthorised(enteredPassword) { var result; if(enteredPassword=="password") { result=true; } else { result=false; } return result; } function buttonClicked() { var isAuthorised = isAccessAuthorised("enteredPassword").value; if(isAuthorised==true) { document.getElementById("output").innerHTML=<p>Access authorised</p>; } else { document.getElementById("output").innerHTML=<p>Access denied</p>; } } </script> </head> <body> <form> <input type="text" id="username" /> <br/> <input type="text" id="enteredPassword" /> <br/> <input type="button" onClick="buttonClicked()" value="Login"> </form> <div id="output"> </div> </body> </html> Hi, I'm just starting out with a few bits of javascript and have hit a problem. The story is this: I have a basic HTML page that I want to display using a different css file depending on the page that the request comes from. I though I'd do this by appending "?cs=a" or "?cs=b" depending on the calling page. My problems are occuring whilst trying to read the data in the URL (querystring?) The code below is meant to be a bit of a debugger sort of affair in that it should display the variables but for the life of me I can't get it to work. The problem is that none of the variables seem to be getting populated with data, therefore nothing is displayed on the page and no css file is loaded. I'm pretty sure its something relatively simple so would appreciate if an expert could cast their eye over what I have below and point out the error of my ways... Code: <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <!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> <SCRIPT type="text/javascript"> var thequerystring = new String(Request.QueryString("cs")); if (thequerystring == "a") { cssfile = "css1.css"; } if (thequerystring == "b") { cssfile = "css2.css"; } document.write('<link href="'+cssfile+'" type="text/css" rel="stylesheet">'); </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p><span class="texttype">hello</span></p> this should change the format of the text depending on the css file that was loaded... in theory!! <p> </p> <p>Here is a list of the variables and their values... <script type="text/javascript"> document.write('<b>Some variables...</b><br>'); document.write('cssfilename: '+cssfile+'<br>'); document.write('Querystring text: '+thequerystring+'<br>'); </script> </p> <a href="javascript: history.go(-1)">Back <-- </a> </body> </html> Many thanks in advance Dan hi. i know a little php, but new to javascript. much of the syntax is identical. i'm reading the new rhino book (flanagan 6th). in it, where he introduces METHODS, he says "When we combine FUNCTIONS with OBJECTS we get METHODS". Then he creates an empty ARRAY: Code: var a = []; then he uses the "push() method" to add elements to the array. Code: a.push(1,2,3); uh, methods are for *objects* right? Yet he is using them on an ARRAY. Can somebody help me see the light on how an array can magically becomes an object that is manipulated by a "method"? I mean, the array is still an array, no? It never actually becomes an object, right? Yet we still use a *method* to manipulate it. See my conceptual quandry? Not much programming experience, but some C++ and Python. I would like to make a web page that 1. flashes and image for 1 second 2. flashes a a pair of images for 1 second 3. displays an image and waits 4. Wait for a certain correct keystroke to be entered. 5. Repeat 1-4 a few hundred times. ^The above would iterate through a loop, say of 300 counts, and sub-iterate through an array of images, say 30, going through all 30 images 10 times for example. Oh, and the array elements would be displayed in random order. Also, I would like to keep track of errors (wrong keystroke) and time it took to enter correct keystroke. I would prefer that this webpage work on the iphone, even older ones. Java is limited on iphone? I tried playing a Java chess game and had no luck on iphone. So, would I be able to do this using Javascript? If not, Java would be best? As I said, I would prefer iphone compatibility, but it is not required. I just want to know which one I should use before I bury my nose in a book about programming Java or Javascript. hi. i know a little php, but new to javascript. much of the syntax is identical. in reading the new rhino book (flanagan 6th), he gives the following example: Code: var square = function(x) { return x*x; }; okay, but then he does this: Code: square(plus1(y)) as an example of "invoking two functions in one expresson". (Prior he gives an example of defining a function with plus1, which is how I normally think of functions.) uh, square is a *variable*, but he is using it as a FUNCTION. Can somebody help me understand how this can be? how it works? I'm having trouble conceptualizng how we use a variable as a function. |