JavaScript - Moving 2 Images With 2 Seperate Functions. One Image Works The Other Doesn't
Code:
function move_user_img(str) { var step = 25; // change this to different step value switch(str) { case "down": var x = document.getElementById('imageUser').offsetTop; x = x + step; document.getElementById('imageUser').style.top = x + "px"; break; case "up": var x = document.getElementById('imageUser').offsetTop; x = x - step; document.getElementById('imageUser').style.top = x + "px"; break; case "left": var y = document.getElementById('imageUser').offsetLeft; y = y - step; document.getElementById('imageUser').style.left = y + "px"; break; case "right": var y = document.getElementById('imageUser').offsetLeft; y = y + step; document.getElementById('imageUser').style.left = y + "px"; break; } } function move_report_img(str) { var step = 25; // change this to different step value switch(str) { case "down": var x = document.getElementById('imageReport').offsetTop; x = x + step; document.getElementById('imageReport').style.top = x + "px"; break; case "up": var x = document.getElementById('imageReport').offsetTop; x = x - step; document.getElementById('imageReport').style.top = x + "px"; break; case "left": var y = document.getElementById('imageReport').offsetLeft; y = y - step; document.getElementById('imageReport').style.left = y + "px"; break; case "right": var y = document.getElementById('imageReport').offsetLeft; y = y + step; document.getElementById('imageReport').style.left = y + "px"; break; } } Code: <div id ="display" style="width:640px; height:480px; overflow:hidden;"> <div> <img src =" <?php echo UPLOADPATH . $userImage; ?> " style = "position:absolute;" id="imageUser"/> </div> <div id ="imageReport"> <img src = " <?php echo $reportImage; ?> " style = "opacity:0.25;height:700px; width:450px;" /> </div> </div> <div style="position:absolute; top:550px; left:100px;"> <p>Control User Image</p> <input type=button onClick=move_user_img('up') value='Up'> <input type=button onClick=move_user_img('left') value='Left'> <input type=button onClick=move_user_img('right') value='right'> <input type=button onClick=move_user_img('down') value='down'> </div> <div style="position:absolute; top:650px; left:100px;"> <p>Control Report Image</p> <input type=button onClick=move_report_img('up') value='Up'> <input type=button onClick=move_report_img('left') value='Left'> <input type=button onClick=move_report_img('right') value='right'> <input type=button onClick=move_report_img('down') value='down'> </div> Similar TutorialsSo this is my first thread and I am a noob at javascript so please forgive obvious mistakes. I am try to make images float across the screen horizontally. Ideally I would like them to come from both sides and be at different y positions. The problem I am having is that I can only seem to get one to move at a time. Another problem is that when they move off to the right of the screen it expands the viewable size of the site. So here's what I've come up with thus far. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head> <title>Image Mover</title> <style> DIV.movable { position:absolute; } body { background-color: #0CF; } </style> <script language="javascript"> var x = 5; //Starting Location - left var y = 5; //Starting Location - top var dest_x = 1000; //Ending Location - left var dest_y = 5; //Ending Location - top var interval = 1; //Move 10px every initialization function moveImage() { //Keep on moving the image till the target is achieved if(x<dest_x) x = x + interval; if(y=dest_y) y = y + interval; //Move the image to the new location document.getElementById("cloud").style.top = y+'px'; document.getElementById("cloud").style.left = x+'px'; //if ((x+interval < dest_x) && (y+interval < dest_y)) { //Keep on calling this function every 100 microsecond // till the target location is reached window.setTimeout('moveImage()',100); } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body background="backgroundgradient.png" onload="moveImage()"> <div id="cloud" class="movable"> <img src="cloud01.png" /> </div> <script language="javascript"> var x = -100; //Starting Location - left var y = 5; //Starting Location - top var dest_x = 1500; //Ending Location - left var dest_y = 5; //Ending Location - top var interval = 1; //Move 10px every initialization function moveImage01() { //Keep on moving the image till the target is achieved if(x<dest_x) x = x + interval; if(y=dest_y) y = y + interval; //Move the image to the new location document.getElementById("plane").style.top = y+'px'; document.getElementById("plane").style.left = x+'px'; //if ((x+interval < dest_x) && (y+interval < dest_y)) { //Keep on calling this function every 100 microsecond // till the target location is reached window.setTimeout('moveImage01()',10); } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body background="web_layout/backgroundgradient.png" onload="moveImage01()"> <div id="plane" class="movable"> <img src="plane.png" /> </div> </body> </html> Any help is greatly appreciated. Thanks hi, I am fairly new to jquery and would like som direction on how to complete this menu. I have a list which has 6 bg images which have on and active state images. these are are currenly changing when you hover using the a:hover css. my question is i have a fairly large page and as you scroll down the menu follows the top of the screen but what i would like to happen is when the menu reaches a certain point on the page the menu item that it corrosponds to becomes active (changes to the on state bg image). i have an idea that as you scroll down the page and you get to a certain position on the page you would remove the classes for all of them. use the selecter to select my id and add a special class with that specific bg image on it. the only part i am struggling with is how would i determin how far down the page i am i know theres a function called .position() and you can use position.top. but not sure how i can use that to help me. if you could point me in the direction or just a hint that would be really helpful. thanks in advance Hello everyone I have just found this wonderful forum through Dr Google whilst looking for an answer to my incredibly frustrating question! I am an OU student it is for an assignment I just cannot find the answer in any of the books and searching the net has got me nothing but so far wasted 3 hours Here is the code snippet: Code: // candidates var candidateArray = ['Mr R Green...', 'Ms O Brown...', 'Ms Y Black...', 'Mr G White...', 'Ms B Grey....','Ms I Blue....', 'Mr V Pink....']; // online votes var onlineVotesArray = [21,47,23,11,56,47,30]; // paper votes var paperVotesArray = [12,4,20,11,5,4,17]; //total votes var totalVotesArray = (candidateArray.length); First I had to add a new array called totalVotes and assign a length to it the same as candidateArray, I have done this in the last 2 lines I think this is correct, the question did stipulate that if the candidate array was changed then so would the total votes array hence linking it via length. Now here is where I am at a complete loss The exact wording is as follows: Use a for loop to calculate the total votes for each candidate according to the following structured english: for each array position add the element at that position in the online vote array to the element at the position in the paper vote array. store the result at the corresponding position in the total votes array end for I have been scratching my head for 3 hours now, I have to have this assignment uploaded before midnight to my tutor or I am in the poo Any help really really appreciated. Thanks in advance I have a website at: http://www.zionism101.org/defaultfornow.aspx The page works on Google Chrome, Mozilla Firefox, and IE-9. It sort-of works on IE-8, however, the problem is that on IE-8, there is about 2 seconds where everything is shown on top of everything else in a mess. This is bad. The website is unusual in that it uses a menu to slide screens from right to left. This has implications. For instance, I need the menu to appear on all screens, so I use absolute positioning, and then use javascript to calculate the center position. The same goes for a logo image. And on top of that, some screens (which are really DIVs) have items positioned by absolute and relative positioning within them, and those positions are often calculated via javascript (and then set). On IE-8, the result is not good. I think what is happening is that the browser first shows everything as it appears before javascript is run, and then slowly the javascript is run, which puts everything in the correct position. So initially, not only is everything in the wrong position, but different DIVs appear on top of each other. I could tell every user to get IE-9 or chrome, but thats not a good solution. Thanks, Gid P.S. one solution might be to make the screen go black for an instant, until everything has settled down. If thats the only solution, how would I do that? P.P.S. there are actually 3 pages in the site: the login page, the logout page, and the founders page. Everytime the user switches between them, the jumble for 2 seconds occurs. Am I doing something wrong here? I have two anonymous functions to validate two different forms on two different pages. They both work on the individual page, though when I try and put them in the same script.js folder only the top function seems to work. Code: <script type="text/javascript"> // Form Validation / Catalog Template ---------------------------------------------------------------------------------------------------------------------- document.getElementById("formValidation").onsubmit = function(){ if(document.getElementById("reqAddrCont").value == ""){ document.getElementById("reqAddrCont").className = "error"; return false; }if(document.getElementById("reqAddrName").value == ""){ document.getElementById("reqAddrName").className = "error"; return false; }if(document.getElementById("reqAddr1").value == ""){ document.getElementById("reqAddr1").className = "error"; return false; }if(document.getElementById("reqAddr6").value == ""){ document.getElementById("reqAddr6").className = "error"; return false; }if(document.getElementById("reqAddrState").value == "0"){ document.getElementById("reqAddrState").className = "error"; return false; }if(document.getElementById("reqAddrPost").value == ""){ document.getElementById("reqAddrPost").className = "error"; return false; }if(document.getElementById("reqAddrPhone").value == ""){ document.getElementById("reqAddrPhone").className = "error"; return false; }if(document.getElementById("reqAddrEMail").value == ""){ document.getElementById("reqAddrEMail").className = "error"; return false; }else{ return true; } }; // Form Validation / New Account Template -------------------------------------------------------------------------------------------------------------------------- document.getElementById("formValidationAccount").onsubmit = function(){ if(document.getElementById("AcctName").value == ""){ document.getElementById("AcctName").className = "error"; return false; }if(document.getElementById("AcctTitle").value == ""){ document.getElementById("AcctTitle").className = "error"; return false; }if(document.getElementById("AcctCompany").value == ""){ document.getElementById("AcctCompany").className = "error"; return false; }if(document.getElementById("AcctAddress1").value == ""){ document.getElementById("AcctAddress1").className = "error"; return false; }if(document.getElementById("AcctAddress2").value == ""){ document.getElementById("AcctAddress2").className = "error"; return false; }if(document.getElementById("AcctAddress6").value == ""){ document.getElementById("AcctAddress6").className = "error"; return false; }if(document.getElementById("AcctState").value == "0"){ document.getElementById("AcctState").className = "error"; return false; }if(document.getElementById("AcctPost").value == ""){ document.getElementById("AcctPost").className = "error"; return false; }if(document.getElementById("AcctCountry").value == ""){ document.getElementById("AcctCountry").className = "error"; return false; }if(document.getElementById("AcctPhone").value == ""){ document.getElementById("AcctPhone").className = "error"; return false; }if(document.getElementById("AcctLogin").value == ""){ document.getElementById("AcctLogin").className = "error"; return false; }if(document.getElementById("AcctLogin2").value == ""){ document.getElementById("AcctLogin2").className = "error"; return false; }if(document.getElementById("AcctPassword").value == ""){ document.getElementById("AcctPassword").className = "error"; return false; }if(document.getElementById("AcctPasswordDupe").value == ""){ document.getElementById("AcctPasswordDupe").className = "error"; return false; }else{ return true; } }; </script> I'm still kinda new at this. Please bear with me..I'm trying to make all imgs move in different directions using the following code. I was givin the code and I need to insert something into it so this will work. I just can't understand it and WANT to ..driving me NUTTY. 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> <title>BUZZ</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> var widthMax = 0; var heightMax = 0; var buzzSpeed = new Array(3); buzzSpeed[0] = 10; var xPosition = new Array(3); xPosition = -20; var yPosition = new Array(3); yPosition[0] = 0; var xDirection = new Array(3); xDirection[0] = "right"; var yDirection = new Array(3); yDirection[0] = "down"; function setBug(newStartPoint) { widthMax = document.documentElement.clientWidth; heightMax = document.documentElement.clientHeight; setInterval("flyBug(0)", 30); } function flyBug(curBug) { var activeBug = document.getElementById("bugImage" + curBug); var activeElement = document.getElementById("bugElement" + curBug); if (xDirection[curBug] == "right" && xPosition[curBug] > (widthMax - activeBug.width - buzzSpeed[curBug])) xDirection[curBug] = "left"; else if (xDirection[curBug] == "left" && xPosition[curBug] <= 0) xDirection[curBug] = "right"; if (yDirection[curBug] == "down" && yPosition[curBug] > (heightMax - activeBug.height - buzzSpeed[curBug])) yDirection[curBug] = "up"; else if (yDirection[curBug] == "up" && yPosition[curBug] <= 0) yDirection[curBug] = "down"; if (xDirection[curBug] == "right") xPosition[curBug] = xPosition[curBug] + buzzSpeed[curBug]; else if (xDirection[curBug] == "left") xPosition[curBug] = xPosition[curBug] - buzzSpeed[curBug]; else xPosition[curBug] = xPosition[curBug]; if (yDirection[curBug] == "down") yPosition[curBug] = yPosition[curBug] + buzzSpeed[curBug]; else if (yDirection[curBug] == "up") yPosition[curBug] = yPosition[curBug] - buzzSpeed[curBug]; else yPosition[curBug] = yPosition[curBug]; activeElement.style.left = xPosition[curBug] + document.documentElement.scrollLeft + "px"; activeElement.style.top = yPosition[curBug] + document.documentElement.scrollTop + "px"; } window.onresize = setBug; </script> </head> <body onload="setBug()"> <div id="bugElement0" style="position:absolute; left:20px; top:0px;"> <img id="bugImage0" src="bug.jpg" alt="buggy" height="48" width="48" /></div> <div id="bugElement1" style="position:absolute; left:25%; top:75%;"> <img id="bugImage1" src="bug.jpg" alt="buggy1" height="48" width="48" /></div> <div id="bugElement2" style="position:absolute; left:40%; top:48%;"> <img id="bugImage2" src="bug.jpg" alt="buggy2" height="48" width="48" /></div> <div id="bugElement3" style="position:absolute; left:58%; top:58%;"> <img id="bugImage3" src="bug.jpg" alt="buggy3" height="48" width="48" /></div> <div id="bugElement4" style="position:absolute; left:90%; top:75%;"> <img id="bugImage4" src="bug.jpg" alt="buggy4" height="48" width="48" /></div> </body> </html> I need to make it so that when a user moves the mouse over an image it appears enlarged in a seperate div tag when the user moves their mouse over the image The problem is that the image just enlarges and makes a copy of itself in the div tag it is already in... this is the code: <td width="55" height="55"><div id="hello"><img src="jpegs for Thu/Copy of Misc/ajam.jpg" onmouseover="<div id = "Enlargedimage"><img src="jpegs for Thu/Copy of Misc/ajam.jpg"/> width="55" height="55"/></div></td> any help would be greatly appreciated Hello, I'm newbie in javascript, but i want to make an moving image. In time it should change to other image with other button. Also it could be changed by user. The change should be dynamic like moving from left to right. ^^ Any advices, tutorial links or smthing.. Thx Hi there folks. I am a bit stuck with a little code. I am making a online yearbook entry and I wanted an image of myself animate/move from the top left hand to the bottom right of the screen. I also wanted to allow people reading it the option to change bg colour and text size - but I have managed to do those. The difficulty I am having is with moving the image, could anybody suggest any simple codes because I am new to this and don't want my head spinning before I go any further! Any help is greatly appreciated. Hi, I'm noob , but i have nice idea i want to do it but i can't .. i tried many ways to do it .. but didn't work any of them .. the idea is move the foot to room no.1 .. but i want to see the foot moving on the red line to the room like this pic : Hello, I am trying to move an image down 20px each time the button is clicked, but I can only get it to move down once. I see what I am doing wrong, but I'm not sure how to fix it. I don't know how to store the updated position of the image in a variable. Code: <center> <input type="button" value="Click" onClick="moveDown()"/> </center> <img id="Ball" src="ball.jpg" style="position:absolute; top:100; left:100;"/> <script language="JavaScript"> var Image = document.getElementById("Ball"); var Position = 100; function moveDown() { Image.style.top = Position + 20 } </script> Thanks, Celia Hey guys, I was trying to make a Javascript game that moves an image across the screen randomly. Instead of executing properly, it just shows the image's starting point, and stops. No movement. Is there anyway I could fix this? Thanks, Fizz. Code: <html> <head> <title>Image Mover</title> <style> DIV.movable { position:absolute; } </style> </head> <script language="javascript"> function Start() { var x = 5; //Starting Location - left var y = 5; //Starting Location - top var dest_x = Math.floor(Math.random()*650); //Ending Location - left var dest_y = 500; //Ending Location - top var interval = 10; //Move 10px every initialization moveImage(); } function NewDest() { var x = 5; //Starting Location - left var y = 5; //Starting Location - top var dest_x = Math.floor(Math.random()*650); //Ending Location - left var dest_y = 500; //Ending Location - top var interval = 10; //Move 10px every initialization moveImage(); } function moveImage() { //Keep on moving the image till the target is achieved if(x < dest_x) x = x + interval; if(y < dest_y) y = y + interval; //Move the image to the new location document.getElementById("ufo").style.top = y+'px'; document.getElementById("ufo").style.left = x+'px'; if ((x+interval < dest_x) && (y+interval < dest_y)) { //Keep on calling this function every 100 microsecond // till the target location is reached window.setTimeout('moveImage()',30); if (x == dest_x) && (y == dest_y) { NewDest(); } } } </script> <body onload="Start()"> <div id="ufo" class="movable"> <img src="Mouse.jpg" alt="mouse" WIDTH = 30/> </div> </body> </html> My code is: Code: <html> <head> <script type='text/javascript'> winx=220 winy=176 self.resizeTo(winx,winy); </script> <img id="default" style="z-index: 0;left: 0; position: absolute; top: 0px" height=32 width=32 align=baseline border=0 hspace=0 src='save.gif'></p> <script type="text/javascript"> document.getElementById("default".style.top = '0px'; document.getElementById("default".style.left = '0px'; </script> The image shows up, but it doesn't move. I can't seem to find out what I'm doing wrong. Edit: Finally spotted it, I was missing a ")" ._. Hello everyone. I want to move my image through table cells by using arrow buttons. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Move</title> <style type="text/css" > table { background-color:#FFCC00; margin-top: 100px; margin-bottom: 100px; } </style> </head> <body onload="setup()"> <script type="text/JavaScript" onkeydown="handleKey(event)"> document.write('<table border="1" cellspacing="0" cellpadding="10">'); var count =0 for (var row=0; row<20; row++) { document.write('<tr>'); for (var col=0; col<20; col++) { idnmr = count count++ document.write('<td style="border:0"; id="idnmr";>'); document.write('</td>'); } document.write('</tr>'); } function setup() { row=0; col=0; insertKnight(row,col); } function handleKey(e) { if (typeof e !='object') e=window.event; if (e.type == 'keydown' && (e.keyCode ==27 || (e.keyCode >= 37 && e.keyCode <=40))) { switch (e.keycode) { case 37: dC= -1; dR = 0; break; case 38: dC= +1; dR=0; break; case 39: dC = 0; dR = +1; break; case 40: dC= 0; dR=-1; break; } emptyCell(row,col); function emptyCell(row,col) { var id = 'r' + row + 'c' + col; var cell= document.getElementById(id); if(cell) cell,innerHTML=''; } row +=dR; col +=dC; //insert image insertKnight(row,col); return false; function insertKnight(row,col) { var id = 'r' + row + 'c' + col; var cell = document.getElementById(id); var colour = cell.className; if (colour != 'white') { var knight='cherry.png'; } else { var knight= 'cherry.png'; function eraseImage(row,col) { var id = 'r' + row + 'c' + col; document.getElementById(id).innerHTML = ''; } cell.innerHTML = '<img src=" ' + knight + ' " alt="' + colour + 'knight" />'; } document.getElementById('debug').innerHTML = 'r='+row+' c='+col; function drawImage(row,col) { var id = 'r' + row + 'c' + col; document.getElementById(id).innerHTML = '<img src="cherry.png"/>'; } </script> </body> </html> This is my code. Now i have problems with the eraseImage and drawImage functions. They just don't work. Any help will be appreciated. Thank you hi all, I want to be able to move an image from a left or right when tilting my ipad. when tilted the the right the image moves to the right according to the angel tilted and do the same to the other direction. the image is doubled (or more) the size of the stage (1024x768). I can't use Flash for obvious reasons so looking at other options. thanks Hello all! I am fairly experienced in HTML but javascript I am useless with. My website can be found here; http://mgwalker.site90.com/index.html If you would be as kind as to load it in Chrome and in firefox, in firefox the changing image pops up on the top right of the screen. In Chrome it is centered in the div, as it should be... Please help I have no idea why this would happen! I've put together a couple of scripts, in order that I can make an image move left or right on the x-axis, depending on the LR (left/right) read-out from the accelerometer of an iPhone. However, it's not working at the moment, so could anyone possibly see what I've missed out - I've worked on it that long, that I think I'm missing something obvious!! THANKS!! Code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>onlywebpro.com</title> </head> <body> <h2>Device Orientation with HTML5 | onlywebpro.com</h2> <img src="Car4.png" id="car" style="position:relative;top:200px;left:200px; "><br> <script type="text/javascript"> if (window.DeviceOrientationEvent) { console.log("DeviceOrientation is supported"); window.addEventListener('deviceorientation', function(eventData) { var LR = eventData.gamma; deviceOrientationHandler(LR); var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -400; // back to the left clearTimeout(tim); } } }, false); } else { alert("Not supported on your device or browser. Sorry."); } var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -878; // back to the left clearTimeout(tim); } } </script> </body> </html> The code below allows the user to hover over 1 object and it not only replaces the object but also shows an additional object between the buttons. It works great in Firefox, but does not in Internet Explorer. HELP webpage: http://www.isp.ucar.edu/ ------------ standard mouseover commands are used in index.php <CODE> <a href="http://www.tiimes.ucar.edu/beachon/" onMouseOver="imgOn('img1')" onMouseOut="imgOff('img1')"> <img src="images/buttons/button-beachon.gif" alt="BEACHON" width="181" height="74" border="0" id="img1" /></a> </CODE> ------------ <CODE> if (document.images) { img1on = new Image(); img1on.src = "images/buttons/button-beachon-on.gif"; img1off = new Image(); img1off.src = "images/buttons/button-beachon.gif"; img2on = new Image(); img2on.src = "images/buttons/button-bgs-on.gif"; img2off = new Image(); img2off.src = "images/buttons/button-bgs.gif"; img3on = new Image(); img3on.src = "images/buttons/button-iam-on.gif"; img3off = new Image(); img3off.src = "images/buttons/button-iam.gif"; img4on = new Image(); img4on.src = "images/buttons/button-nvia-on.gif"; img4off = new Image(); img4off.src = "images/buttons/button-nvia.gif"; img5on = new Image(); img5on.src = "images/buttons/button-utls-on.gif"; img5off = new Image(); img5off.src = "images/buttons/button-utls.gif"; img6on = new Image(); img6on.src = "images/buttons/button-water-on.gif"; img6off = new Image(); img6off.src = "images/buttons/button-water.gif"; img7on = new Image(); img7on.src = "images/buttons/button-exploratory-on.gif"; img7off = new Image(); img7off.src = "images/buttons/button-exploratory.gif"; // second image that does not appear in original button space img1ad = new Image(); img1ad.src = "images/buttons/beachon-overview-sm.gif"; img2ad = new Image(); img2ad.src = "images/buttons/bgs-overview-sm.gif"; img3ad = new Image(); img3ad.src = "images/buttons/iam-overview-sm.gif"; img4ad = new Image(); img4ad.src = "images/buttons/nvia-overview-sm.gif"; img5ad = new Image(); img5ad.src = "images/buttons/utls-overview-sm.gif"; img6ad = new Image(); img6ad.src = "images/buttons/water-overview-sm.gif"; img7ad = new Image(); img7ad.src = "images/buttons/exploratory-overview-sm.gif"; } { function imgOn(imgName) { if (document.images) { document[imgName].src = eval(imgName + "on.src"); document["holder"].src = eval(imgName + "ad.src"); } } } function imgOff(imgName) { if (document.images) { document[imgName].src = eval(imgName + "off.src"); document["holder"].src = "images/buttons/isp-overview-sm.gif"; } } </CODE> Hey guys I'm need to put a photo slideshow on my website with a lot of images. I don't want all the images to download as you come to the website as this would take forever. Are there any pretty simple slideshows that load images just before they are about to come in the view?
Reply With Quote 01-25-2015, 01:07 PM #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 How will the program know which image is "about" to come into view? Or are they viewed sequentially? If so there is no need for preloading images to take "forever". Preload the first (say) 5 and then preload the rest while the user is viewing the first ones. Or when each "next" image is selected for viewing preload the next following one. |