JavaScript - Fullscreen Javascript Image Gallery Sizing
i'm trying to get this effect
http://css-tricks.com/3458-perfect-f...kground-image/ except, instead of using an image, i would like to use a javascript image gallery. I was playing around with smoothgallery2.0 but I don't really care which I use as long as I'm just displaying images (no text) and there is a smooth fade effect (since the images are pretty high res). thanks so much in advance! Similar TutorialsHello, I am working on a page that has a jQuery full browser BG image and I am trying to also utilize a MooTools gallery. There seems to be some interference between the two JavaScripts as only one works (whichever one is last in order in the header of the HTML document). Links: http://www.courtneyhunt.com.au/press_bg.html http://www.courtneyhunt.com.au/press_gallery.html I am a complete novice with JavaScript so if anyone could help that would be great. Thank you in advance. Hello. I am having trouble with a simple image gallery with navigational buttons including "first", "next", "previous", and "last"; and making a drop-down archive menu. 1. For the most part, the image gallery works. The problem is that when a user clicks on "next", and then "prev", the last image is not displayed. On the other hand, if a user clicks "prev", and then "next" the last image is displayed(works normally). 2. The way I am displaying the last image, the function last(), is not efficient. It simply refreshes the page in order to display the last image. Basic overview: The images follow a simple standard: page1, page2, page3,...page64; they are in a subfolder "img". The function changeImage() changes the image from the prev, to the next. The image gallery displays the last image in the gallery; when a user clicks on 'prev' it goes to the previous image, and go to the next image when clicked on 'next'. If the current image is the last image, and the user clicks on 'next', it goes to the very first image. Here is the code (in the <HEAD> tags): Code: <script language="JavaScript"><!-- which_image_loaded = -1; NUMBER_OF_IMAGES = 64; current_comic = 0; ImageNames = new Array; ImageNames.length = NUMBER_OF_IMAGES - 1; for (counter = 0; counter < NUMBER_OF_IMAGES; counter++){ file_number = counter + 1; filename = ("../img/page" + file_number + ".png"); ImageNames[counter] = filename; } function changeImage(direction) { which_image_loaded += direction; current_comic = which_image_loaded + 1; if (which_image_loaded < 0) which_image_loaded = NUMBER_OF_IMAGES - 1; if (which_image_loaded == NUMBER_OF_IMAGES) which_image_loaded = 0; if(current_comic <= 0){ which_image_loaded--; } document.myimage.src = ImageNames[which_image_loaded]; } function first(){ which_image_loaded = 0; current_comic = 1; document.myimage.src = ImageNames[0]; } function last(){ window.location='http://www.bearoncampus.com'; } and in the <BODY> tags Code: <img src="img/page64.png" alt="New comic not available." name="myimage" width="725" height="275"> <form> <input type="button" value="FIRST" onClick="first()"/> <input type="button" value="PREV" onClick='changeImage(-1);' /> <input type="button" value="NEXT" onClick='changeImage(1);' /> <input type="button" value="LAST" onclick="last()" /> </form> My guess is the code is not working properly due to the initial values of the counter. Last, is there a way to display the current image "myimage.src" using a dropdown menu with each option value as each image? I have done this with window.location, but this only redirects to the image location. Much thanks. Any help is greatly appreciated. http://www.muffettandsons.com/specproductstest.html Follow the link above and click on the pic to the right to open the pop up image gallery. For some reason the thumbs do not appear in the left preview pane until a rollover of the preview pane slide bar. This only occurs in IE. Firefox and Chrome both show the thumbs when opened and work just fine. Any help would be greatly appreciated... Thanks Not sure where to even start here. I am trying to build a a small JavaScript image gallery. As you can see in the jpeg image at the link provided, i want the user to be able to change the large image by clicking on the small thumbnails. The thumbnails will also have a roll over where they enlarge slightly. Complicated? I'm not a javascript expert, but i know enough by editing existing code and have saved a bunch of code i've modified. I've googled for javascript image galleries and looked through them but no success... I can understand the clicking on a thumbnail to change the larger image but what gets me is having the thumbnail on top of the larger..as well having a still image at the top left....some sorta layering? anyway some sorta help to get me started would be very helpful... http://www.rossow-web.com/test/RCC_Mockup.jpg thanks! Hi! I'm wondering if somebody here could help me please. I'm trying to develope the image slideshow using PHP and JavaScript. The idea is that the PHP file gets random images from the folder, i'm using session to prevent repeating the same image and then JavaScript generates the fade slideshow using that PHP file. I've come up with the solution to use two img tags in the HTML page, so JavaScript then swap them around and play with opacity, but unfortunately couldn't make it work. Everything I have tried in JavaScript didn't work properly. I'd be grateful for any help and advice guys. Thank you. My PHP code: PHP Code: <?php class images { var $images = Array(); var $imgDir = 'images/'; function getImages() { $images = Array(); if ($dir = opendir($this->imgDir)) { while(($file = readdir($dir)) !== false) { if(preg_match('#(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)#i', $file)) $images[] = $file; } closedir($dir); } return $images; } function getNextImage() { if (($images = $this->getImages()) !== false) { session_start(); if (!isset($_SESSION['image'], $images[$_SESSION['image']])) { $index = mt_rand(0, count($images)-1); } else { $index = $_SESSION['image'] == count($images)-1 ? 0 : $_SESSION['image']+1; } $_SESSION['image'] = $index; return $images[$index]; } return false; } function outputImage() { if (($file = $this->getNextImage()) !== false) { header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Wed, 9 Dec 1981 07:00:00 GMT'); // Date in the past header('Content-type: image/jpg'); readfile($this->imgDir.$file); exit(); } } } $img = new images(); $img->outputImage(); ?> My HTML page: Code: <html> <head> <title>Images</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script type="text/javascript" src="javascript/slideshow2.js" language="javascript"></script> </head> <body onload="startSlideShow();"> <h1>Images</h1> <div id="imageWrap"> <div id="images"> <img id="sampleImgFade" src="images.php" alt="images" style="filter:progid:DXImageTransform.Microsoft.alpha(opacity=0);-moz-opacity:0;-khtml-opacity:0;" width="800" height="600" onload="coverLoaded(this);" /> <img id="sampleImg" src="images.php" width="800" height="600" alt="images" onload="mainLoaded();" /> </div> </div> </body> </html> CSS code: Code: #imageWrap { clear: both; } #images { position: relative; clear: both; } #sampleImgFade { position: absolute; top: 0px; left: 0px; } JavaScript code which doesn't work properly(just to show in which direction I'm going): Code: var img; var loaded = new Array(); loaded['start'] = true; loaded['main'] = false; loaded['cover'] = true; var fade = 0; var i = 0; function getImage() { img = new image(); img.src = "images.php"; } function coverLoaded(obj) { loaded['cover'] = true; setOpacity(obj, 100); window.setTimeout("startFade", 5000); } function mainLoaded() { loaded['main'] = true; if (loaded['start'] && loaded['cover'] && loaded['main']) startFade(); } function startFade() { loaded['start'] = false; loaded['main'] = false; loaded['cover'] = false; fade = window.setInterval("fadeIn()", 50); } function fadeIn() { var obj = document.getElementById("sampleImgFade"); var opacity = getOpacity(obj); if (opacity > 0) { setOpacity(obj, opacity-5); } else { window.clearInterval(fade); document.getElementById("sampleImg").src = "images.php?u="+i++; } } function getOpacity(obj) { if (obj.filters) { return obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity; } else if (obj.style.MozOpacity) { // mozilla return obj.style.MozOpacity*100; } else if (obj.style.KhtmlOpacity) { // konquerer return obj.style.KhtmlOpacity; } else { // not supported return 0; } } function setOpacity(obj, opacity) { if (obj.filters) { obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opacity; } else if (obj.style.MozOpacity) { // mozilla obj.style.MozOpacity = opacity/100; } else if (obj.style.KhtmlOpacity) { // konquerer obj.style.KhtmlOpacity = opacity; } } Hi I am using the css image gallery I got from: http://www.dynamicdrive.com/style/cs...image-gallery/ I want to change the behaviour, currently an image is enlarged when a user hovers over the link/thumbail. I would like to change it so that the main image is instead shown onclick of the thumbnail, and remains enlarged until another click. Is this possible using some javascript? Hi, I'm attempting to add the following functionality to my site. Essentially, two images are displayed with a link "View More". The user clicks "View More" and the two images are replaced by two new images. This can be repeated as required. It's a basic form of slideshow I guess, but after some googling all the tutorials etc available seem to be more aimed at fully blown shows, whereas I believe my problem is much more simple. The images are contained in a directory and are numbered like so: img1.jpg, img2.jpg. img3.jpg and so on. the code I came up with so far is PHP Code: <script type="text/javascript" language="JavaScript"> start = '<img src="gallery/img'; end = '.jpg" width="150" height="200" />'; function getImage() { var n = Math.ceil(Math.random() * 10); // i have 10 images var FirstImg=(start+n+end); var n = Math.ceil(Math.random() * 10); var SecondImg=(start+n+1+end); } /* so now I think I have two variables: FirstImg = <img src="gallery/img1.jpg" width="150" height="200" /> SecondImg = <img src="gallery/img4.jpg" width="150" height="200" /> but i'm now unsure how i'd go about displaying this on the page. ideally the HTML generated would be: <div class="pics"> <p><FirstImg></p> <p><SecondImg></p> <a href="#" onClick="return getImage()">View More</a> </div> */ </script> Am I on the right lines here or am I way off?? Appreciate some pointers. thanks a lot. Hi, well making a page fullscreen is one of my favorite topics but whenever I have thought of doing it, I have always received one answer and that is, it is only done with flash. For the first time today I saw one that is not done with flash, can someone tell me how exactly it is done, so I could atlast full my dream of using it ^^ here is the image http://content.screencast.com/users/...04-13_0001.png and here is the link to the page where this fullscreen button exists. http://tutorialzine.com/2010/09/html...deshow-jquery/ Hi, I've investigated contacting the author, but it doesn't look like I'll get a swift response. The script I'm using is hosted here The script is designed to create a fullscreen, scaling background that can be used as a carousel gallery for images, with a caption that floats next to the mouse pointer that either reads 'next' or 'previous'. It works fine but I am attempting to alter the script to do a few things: 1.Make the image take up a proportionate amount of window space - 85% (done) 2.Get rid of the text which appears on rollover(done) 3.Assign an image flip for the proportionally scaled image (this is the one I'm having problems with) I'm trying not to include too much information but it's hard to know where the problem is. I'm fairly sure this is used to set the scaler up on the page: Code: (function(){ var bg=document.getElementById('bg'),float=document.createElement('span'),scale=Scaler(bg); //Create and bind scaler-function addEvent=function(el,on,fn){el.attachEvent?el.attachEvent('on'+on,fn):el.addEventListener(on,fn,false)}, //Function for cross-borwser addEvent move=function(e){ float.style.left=(e=e||window.event).clientX+20+'px'; float.style.top=e.clientY+20+'px'; if(float.nxt!=(e.clientX>(document.body.offsetWidth/2)))float.innerHTML=(float.nxt=!float.nxt)?'':''; //Change html only if needed }, swap=function(e){ var key=(e=e||window.event).type=='MouseOver'?(e.clientX>(document.body.clientWidth/2)?40:37):e.keyCode; if(key>36&&key<41){ var data=scale(key>38?'+1':'-1'),l=data.els.length; for(var i=0;i<l;i++)data.els[i].style.height=i==data.to?'85%':'0px'; } } I've then used a simple imageflip function and implemented it here Code: addEvent(bg,'mouseout',function('BNB_mouseon()'){float.style.display='none'}); //Hide floater when not over image addEvent(bg,'mouseover',function('BNB_mouseon()'){float.style.display='block'}); Where 'bg' stands for the background image div. I've been scratching my head about this for quite a while now, so any advice is appreciated! I'm attempting to impliment it on the website http://www.freddydewemathews.com/, for a little context Hi, I'm fairly new to javascript, I created a javascript image gallery using a tutorial found on web monkey. Please see below: Code: <script language="JavaScript" type="text/javascript"> <!-- var interval = 1500; var random_display = 0; var image_dir = "images/exhibition/" var ImageNum = 0; imageArray = new Array(); imageArray[ImageNum++] = new imageItem(image_dir + "exhibition-sealskinz.png"); imageArray[ImageNum++] = new imageItem(image_dir + "exhibition-orchard.png"); var number_of_image = imageArray.length; function imageItem(image_location) { this.image_item = new Image(); this.image_item.src = image_location; } function get_ImageItemLocation(imageObj) { return(imageObj.image_item.src) } function randNum(x, y) { var range = y - x + 1; return Math.floor(Math.random() * range) + x; } function getNextImage() { if (random_display) { ImageNum = randNum(0, number_of_image-1); } else { ImageNum = (ImageNum+1) % number_of_image; } var new_image = get_ImageItemLocation(imageArray[ImageNum]); return(new_image); } function getPrevImage() { ImageNum = (ImageNum-1) % number_of_image; var new_image = get_ImageItemLocation(imageArray[ImageNum]); return(new_image); } function prevImage(place) { var new_image = getPrevImage(); document[place].src = new_image; } function rotateImage(place) { var new_image = getNextImage(); document[place].src = new_image; var recur_call = "rotateImage('"+place+"')"; timerID = setTimeout(recur_call, interval); } // --> </script> However unfortunately there are two issues, one is IE6 is coming up with javascript errors and IE7 gets an error when you click the previous button on the first image. The buttons look like this: Code: <div id="left-arrow-container"><a href="#" onClick="prevImage('rImage'); clearTimeout(timerID)"><img src="images/left-arrow.png" alt="left arrow" name="leftarrow" width="58" height="37" border="0" id="leftarrow" /></a></div> <div id="see-the-whole-project"> see the whole project</div> <div id="right-arrow-container"><a href="#" onClick="rotateImage('rImage'); clearTimeout(timerID)"><img src="images/right-arrow.png" alt="right arrow" name="rightarrow" width="58" height="36" border="0" id="rightarrow" /></a></div> Being new to javascript I don't know how to get round these issues so if anyone could advise me I would really appreciate it. Thanks Gary This is my first javascript game and it's pretty much built of code I've gathered over time and cleaned up. Here's a manipulated screenshot of what I'm trying to accomplish. You're an ant and you want those goodies on the map as quickly as possible! click this link to view a bigger manipulated screenshot click this link to view the goodies (items) The ant is the playable character you control by using the arrow keys. Every time you load the page, or click "restart game", three new items will spawn randomly on the level and the time will be reset to 0 seconds. An arrow key must be pressed to start the time counter and the game itself. There are only 5 items so far, cheese, apple, banana, candy and donut. The items are supposed to be collected as quickly as possible, when the last item has been collected (by simply running over it) the game will end, save the time and display a hi-score list. Time limit is 30 seconds, the game will display a classic "GAMER OVER" if the limit is overrided. Problems I'm trying to solve: 1: Fullscreen mode (and make the ant actually STAY on the screen) I want the game level to adapt itself to the computer screen. The game dimensions are 1000x600px at the moment but the ant does not respect the level dimensions. Screenshot: http://i41.tinypic.com/kc1j81.jpg. I have a feeling about that somekind of percental code has to be implented but I've never done this before. (Please note that the size of the ant and the items will remain as they are) 2: Spawning three items randomly on the level I drew 5 items and saved them as 100x100 PNG. Three of these items have to spawn at a random location on the fullscreen level. The LAST item collected must trigger the time counter to stop. The time will later be used on the hi-score list where he/she can type her nickname. This information will be uploaded to a database. 3: 30 second time limit Letting the time counter reach 30 seconds will trigger a "GAME OVER". The only way to try again is page refresh or "restart game". Code: <html> <head> <style type="text/css"> div#game { width:1000px; height:600px; position:absolute; background:#c3c3c3; } </style> <script type='text/javascript'> // movement vars var xpos = 100; var ypos = 100; var xspeed = 1; var yspeed =1; var maxSpeed = 5; // boundary var minx = 0; var miny = 0; var maxx = 1000; // characters movement field, width var maxy =600; // characters movement field, height // controller vars var upPressed = 0; var downPressed = 0; var leftPressed = 0; var rightPressed = 0; function slowDownX() { if (xspeed > 0) xspeed = xspeed - 1; if (xspeed < 0) xspeed = xspeed + 1; } function slowDownY() { if (yspeed > 0) yspeed = yspeed - 1; if (yspeed < 0) yspeed = yspeed + 1; } function gameLoop() { // change position based on speed xpos = Math.min(Math.max(xpos + xspeed,minx),maxx); ypos = Math.min(Math.max(ypos + yspeed,miny),maxy); // or, without boundaries: // xpos = xpos + xspeed; // ypos = ypos + yspeed; // change actual position document.getElementById('character').style.left = xpos + "px"; document.getElementById('character').style.top = ypos + "px"; // change speed based on keyboard events if (upPressed == 1) yspeed = Math.max(yspeed - 1,-1*maxSpeed); if (downPressed == 1) yspeed = Math.min(yspeed + 1,1*maxSpeed) if (rightPressed == 1) xspeed = Math.min(xspeed + 1,1*maxSpeed); if (leftPressed == 1) xspeed = Math.max(xspeed - 1,-1*maxSpeed); // deceleration if (upPressed == 0 && downPressed == 0) slowDownY(); if (leftPressed == 0 && rightPressed == 0) slowDownX(); // loop setTimeout("gameLoop()",10); } function keyDown(e) { var code = e.keyCode ? e.keyCode : e.which; if (code == 38) upPressed = 1; if (code == 40) downPressed = 1; if (code == 37) leftPressed = 1; if (code == 39) rightPressed = 1; } function keyUp(e) { var code = e.keyCode ? e.keyCode : e.which; if (code == 38) upPressed = 0; if (code == 40) downPressed = 0; if (code == 37) leftPressed = 0; if (code == 39) rightPressed = 0; } </script> </head> <body onload="gameLoop()" onkeydown="keyDown(event)" onkeyup="keyUp(event)" bgcolor='gray'> <!-- level --> <div id="game"></div> <!-- ant character --> <img id='character' src='images/ant.png' style='position:absolute;left:500px;top:500px;height:125px;width:200px;'/> </body> </html> Hello, My site has an image gallery with a row of pictures at the bottom. When I load up the page it should show image 1 in the main gallery window, but instead it's showing image in position #10 (the one to the left of #1). You can see what I'm talking about here. When you load the page it's showing the White House, but it should be showing the Green House (position #1 in slider). The White House can't be seen in the slider since it's in position #10, but shows up first int the main window. Is this a javascript issue or what? All JS files can be found here Can anybody help me debug this?? I'm going nuts Thank you So I have a gallery which is displaying images from an array called imgList. When they are displayed I want the user to be able to link directly to the image. Is there a simple way to do this? The JavaScript: Code: //<!-- var imgList = new Array( "images/gallery/1.jpg", "images/gallery/2.jpg", "images/gallery/3.jpg", "images/gallery/5.jpg", "images/gallery/6.jpg", "images/gallery/duo.jpg" ); var clientData = new Array( '', '', '', '', '', '', '' ); var currentMain = 0; var currentMainT = 0; var current_position=0; var all_links=""; function init(){ all_links=document.getElementById('gallery').getElementsByTagName('a'); all_links[0].style.color="#7d3d3d"; ShowMain(current_position); } function color_me(element,color){ element.style.color=color; } function Prev(){ color_me(all_links[current_position],'#000000'); if((current_position-1)>-1){ current_position=current_position-1; } else{ current_position=(all_links.length-1); } ShowMain(current_position); // ShowMainT(current_position); color_me(all_links[current_position],'#7d3d3d'); } function direct_selection(number){ all_links[current_position].style.color="#000000"; current_position=number; ShowMain(current_position); all_links[current_position].style.color="#7d3d3d"; } function Next() { color_me(all_links[current_position],'#000000'); if((current_position+1)<all_links.length){ current_position++; } else{ current_position=0; } ShowMain(current_position); // ShowMainT(current_position); color_me(all_links[current_position],'#7d3d3d'); } function ShowMain(which){ currentMain = which; currentMainT = which; if ( currentMain < 0 ) currentMain = 0; if ( currentMainT < 0 ) currentMainT = 0; if ( currentMain > imgList.length-1) currentMain = imgList.length-1; if ( currentMainT > clientData.length-1) currentMainT = clientData.length-1; document.getElementById('mainImg').src = imgList[currentMain]; document.getElementById('mainText').innerHTML = clientData[currentMainT]; var PD = document.getElementById('Pg'); var PD2 = document.getElementById('Pg2'); document.getElementById("mainText").style.display = 'inline'; // return false; } onload = function() { ShowMain(0); } onload = function() { ShowMainT(0); } //--> //<!-- function preloader(){ // counter var i = 0; // create object imageObj = new Image(); // set image list images = new Array(); images[0]="images/gallery/1.jpg"; images[1]="images/gallery/2.jpg"; images[2]="images/gallery/3.jpg"; images[3]="images/gallery/5.jpg"; images[4]="images/gallery/6.jpg"; images[5]="images/gallery/duo.jpg"; // start preloading for(i=0; i<=3; i++){ imageObj.src=images[i]; } } //--> The HTML where it is displayed: Code: <img id="mainImg" src="images/gallery/1.jpg" style=" border: solid #7d3d3d 5px;" alt="galleryimage" /> Does anyone know of a good webscript slideshow on a loop that I can use in a website ? www.chagfordshow.com We don’t want a database at the moment. Needs to work in all browsers. What I’m looking for :- Change the image every few seconds. Slip into any element of the webpage. All images will be the same size. Some landscape, some portrait. Looking for this to work all in client’s scripting. or maybe AJAX Thanks. Most grateful if anyone can help Hey all, I'm designing a website and i'm doing a section on a portfolio of artwork. wat i would like is to group the work under different headings and for each group to have a thumbnail of an image. when that image is clicked a window is opened which displays all the works in that group as thumbnails as well as an image gallery (larger image of the current image and being able to click on the other thumbnails to view a larger image of it). hope that makes sense. I've been searching all over for scripts bit nothing fits my criteria exactly. going a bit crazy over this, any help or direction much appreciated. peace Hi guys. I wanted to show you a gallery that I am doing. I'm stuck here with some issue. I've made the gallery with the buttons but now I wanted to add a previous and next button but I not being able to do. all the rest is working. the javascript code is this: Code: $(function () { var imgContainers = $('div.tabs > div'); imgContainers.hide().filter(':first').show(); $('div.tabs ul.number_nav a').click(function () { imgContainers.hide(); imgContainers.filter(this.hash).show(); $('div.tabs ul.number_nav a').removeClass('selected'); $(this).addClass('selected'); return false; }).filter(':first').click(); }); the html file is this: 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>gallery</title> <!--CSS--> <link href="style.css" rel="stylesheet" type="text/css" /> <!--JavaScript--> <script type="text/javascript" src="jquery-1.4.2.js"></script> <script type="text/javascript" src="code.js"></script> </head> <body> <div id="gallery"><!--IMG CONTAINER START --> <div class="tabs"> <div id="image_01"> <div class="image"> <img src="image_one.png" width="795" height="395" /> </div> </div> <div id="image_02" > <div class="image"> <img src="image_two.png" width="795" height="395" /> </div> </div> <div id="image_03"> <div class="image"> <img src="and_so_on.png" width="795" height="395" /> </div> </div> <ul class="number_nav"> <li><a href="#image_01">01</a></li> <li><a href="#image_02">02</a></li> <li><a href="#image_03">03</a></li> </ul> <ul class="prev_next_nav"> <li><a href="#">Previous</a></li> / <li><a href="#">Next</a></li> </ul> </div> </div> </body> </html> here is the zip file: http://www.sendspace.com/file/we3lkd can someone help me to make the code to the previous / next code please? I'm not very good ( nothing at all ) with javascript... Hi I want to create an image gallery which has one main image (large size) with a series of smaller thumbnail images below. When you click on one of the smaller images below, I need it to load it into the space above. This series of images will be selected by a PHP script and a MySQL database. The ratios of the images will not always be the same, so the boundry box will need to change width and height accordingly. This will change the height of the page too I guess. Now, the real fly in the ointment is that I really would like the main image to have a drop shadow (gradient based) on all 4 sides of the image. So, good people of the JS Sub-Forum - whats the best way to get this done?! Cheers The Moose Hey all, Effectively what I want is a table displaying 20 thumbnails and above the table to be a large image. When a user clicks a thumbnail I want a relative image to be displayed above. Now obviously I can just set this to reload the page and load the relative image in its space but I was wondering if there was a way of doing this without having to reload the whole page each time. I also want to avoid Iframes as I want this to be as cross-compatible as possible. Thanks all. Dear Friends, I have a javascript image gallery in my website.. it is working Good.. But now i have some problem... i have to get the Loaded image url. i need users to post comments about that image. So i have to get the URL or name of image. This is needed in a text input field... So please see the code of gallery and help me.. The code is below.. Or Check it here http://www.home-palettes.com/gallery.html Code: //add thickbox to href elements that have a class of .thickbox function TB_init(){ $("a.thickbox").click(function(){ var t = this.title || this.name || null; var g = this.rel || false; TB_show(t,this.href,g); this.blur(); return false; }); $("a.thickbox").css({display:"inline"}); } function TB_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link var images_location = 'extensions/thickbox_2' try { if (document.getElementById("TB_HideSelect") == null) { $("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>"); $("#TB_overlay").click(TB_remove); } if(caption==null){caption=""}; $(window).scroll(TB_position); TB_overlaySize(); $("body").append("<div id='TB_load'><img src='"+images_location+"/loadingAnimation.gif' /></div>"); TB_load_position(); if(url.indexOf("?")!==-1){ //If there is a query string involved var baseURL = url.substr(0, url.indexOf("?")); }else{ var baseURL = url; } var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.bmp/g; var urlType = baseURL.toLowerCase().match(urlString); if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images TB_PrevCaption = ""; TB_PrevURL = ""; TB_PrevHTML = ""; TB_NextCaption = ""; TB_NextURL = ""; TB_NextHTML = ""; TB_imageCount = ""; TB_FoundURL = false; if(imageGroup){ TB_TempArray = $("a[@rel="+imageGroup+"]").get(); for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML == "")); TB_Counter++) { var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); if (!(TB_TempArray[TB_Counter].href == url)) { if (TB_FoundURL) { TB_NextCaption = TB_TempArray[TB_Counter].title; TB_NextURL = TB_TempArray[TB_Counter].href; TB_NextHTML = "<span id='TB_next'> <a href='#'>Next ></a></span>"; } else { TB_PrevCaption = TB_TempArray[TB_Counter].title; TB_PrevURL = TB_TempArray[TB_Counter].href; TB_PrevHTML = "<span id='TB_prev'> <a href='#'>< Prev</a></span>"; } } else { TB_FoundURL = true; TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); } } } imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; // Resizing large images - orginal by Christian Montoya edited by me. var pagesize = TB_getPageSize(); var x = pagesize[0] - 150; var y = pagesize[1] - 150; var imageWidth = imgPreloader.width; var imageHeight = imgPreloader.height; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; } } else if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; } } // End Resizing TB_WIDTH = imageWidth + 30; TB_HEIGHT = imageHeight + 60; $("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>"); $("#TB_closeWindowButton").click(TB_remove); if (!(TB_PrevHTML == "")) { function goPrev(){ if($(document).unclick(goPrev)){$(document).unclick(goPrev)}; $("#TB_window").remove(); $("body").append("<div id='TB_window'></div>"); TB_show(TB_PrevCaption, TB_PrevURL, imageGroup); return false; } $("#TB_prev").click(goPrev); } if (!(TB_NextHTML == "")) { function goNext(){ $("#TB_window").remove(); $("body").append("<div id='TB_window'></div>"); TB_show(TB_NextCaption, TB_NextURL, imageGroup); return false; } $("#TB_next").click(goNext); } /* document.onkeydown = function(e){ if (e == null) { // ie keycode = event.keyCode; } else { // mozilla keycode = e.which; } if(keycode == 27){ // close TB_remove(); } else if(keycode == 190){ // display previous image if(!(TB_NextHTML == "")){ document.onkeydown = ""; goNext(); } } else if(keycode == 188){ // display next image if(!(TB_PrevHTML == "")){ document.onkeydown = ""; goPrev(); } } } */ TB_position(); $("#TB_load").remove(); $("#TB_ImageOff").click(TB_remove); $("#TB_window").css({display:"block"}); //for safari using css instead of show } imgPreloader.src = url; }else{//code to show html pages var queryString = url.replace(/^[^\?]+\??/,''); var params = TB_parseQuery( queryString ); TB_WIDTH = (params['width']*1) + 30; TB_HEIGHT = (params['height']*1) + 40; ajaxContentW = TB_WIDTH - 30; ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){ urlNoQuery = url.split('TB_'); $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' onload='TB_showIframe()'> </iframe>"); }else{ $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>"); } $("#TB_closeWindowButton").click(TB_remove); if(url.indexOf('TB_inline') != -1){ $("#TB_ajaxContent").html($('#' + params['inlineId']).html()); TB_position(); $("#TB_load").remove(); $("#TB_window").css({display:"block"}); }else if(url.indexOf('TB_iframe') != -1){ TB_position(); if(frames['TB_iframeContent'] == undefined){//be nice to safari $("#TB_load").remove(); $("#TB_window").css({display:"block"}); $(document).keyup( function(e){ var key = e.keyCode; if(key == 27){TB_remove()} }); } }else{ $("#TB_ajaxContent").load(url, function(){ TB_position(); $("#TB_load").remove(); $("#TB_window").css({display:"block"}); }); } } $(window).resize(TB_position); document.onkeyup = function(e){ if (e == null) { // ie keycode = event.keyCode; } else { // mozilla keycode = e.which; } if(keycode == 27){ // close TB_remove(); } } } catch(e) { alert( e ); } } //helper functions below function TB_showIframe(){ $("#TB_load").remove(); $("#TB_window").css({display:"block"}); } function TB_remove() { $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove();}); $("#TB_load").remove(); return false; } function TB_position() { var pagesize = TB_getPageSize(); var arrayPageScroll = TB_getPageScrollTop(); $("#TB_window").css({width:TB_WIDTH+"px",left: (arrayPageScroll[0] + (pagesize[0] - TB_WIDTH)/2)+"px", top: (arrayPageScroll[1] + (pagesize[1]-TB_HEIGHT)/2)+"px" }); } function TB_overlaySize(){ if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) { yScroll = window.innerHeight + window.scrollMaxY; xScroll = window.innerWidth + window.scrollMaxX; var deff = document.documentElement; var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth; var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight; xScroll -= (window.innerWidth - wff); yScroll -= (window.innerHeight - hff); } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac yScroll = document.body.scrollHeight; xScroll = document.body.scrollWidth; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari yScroll = document.body.offsetHeight; xScroll = document.body.offsetWidth; } $("#TB_overlay").css({"height":yScroll +"px", "width":xScroll +"px"}); $("#TB_HideSelect").css({"height":yScroll +"px","width":xScroll +"px"}); } function TB_load_position() { var pagesize = TB_getPageSize(); var arrayPageScroll = TB_getPageScrollTop(); $("#TB_load") .css({left: (arrayPageScroll[0] + (pagesize[0] - 100)/2)+"px", top: (arrayPageScroll[1] + ((pagesize[1]-100)/2))+"px" }) .css({display:"block"}); } function TB_parseQuery ( query ) { var Params = new Object (); if ( ! query ) return Params; // return empty object var Pairs = query.split(/[;&]/); for ( var i = 0; i < Pairs.length; i++ ) { var KeyVal = Pairs[i].split('='); if ( ! KeyVal || KeyVal.length != 2 ) continue; var key = unescape( KeyVal[0] ); var val = unescape( KeyVal[1] ); val = val.replace(/\+/g, ' '); Params[key] = val; } return Params; } function TB_getPageScrollTop(){ var yScrolltop; var xScrollleft; if (self.pageYOffset || self.pageXOffset) { yScrolltop = self.pageYOffset; xScrollleft = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){ // Explorer 6 Strict yScrolltop = document.documentElement.scrollTop; xScrollleft = document.documentElement.scrollLeft; } else if (document.body) {// all other Explorers yScrolltop = document.body.scrollTop; xScrollleft = document.body.scrollLeft; } arrayPageScroll = new Array(xScrollleft,yScrolltop) return arrayPageScroll; } function TB_getPageSize(){ var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight arrayPageSize = new Array(w,h) return arrayPageSize; } I'm designing my site at the moment and want to include some photos (500 x 331 pixs). I want to have the images load within the same space without the page reloading like flickr. I think it's done using AJAX Javascript or something similar but have been unable to find any tutorials which deal specifically with this although I'm sure there are many (links would be greatfully received). I want to be able to navigate through them with arrows, or a row of numbers or something simlar and straight forward. simlar to these: http://www.itsnicethat.com/articles/3011-things http://www.timgeorgedesign.co.uk/jump_print.html (this is flash I think) I'm using Dreamweaver, and have been working mainly in the design and split views so don't know too much about coding, but I was hoping to find prehaps a few lines of script that I might be able to paste in and edit to make this, as the rest of the page is all done or a decent pre made gallery plug-in. Thanks for any help. |