JavaScript - Simple Image Switcher - I Broke It!
I have a WP theme that before I started tweaking it had an image switcher on the home page. When you click any of the 4 thumbnails under the main header, the image on the right switches to the hi-res version of the thumbnail but now it's broken.
I've re-uploaded Wordpress core, and re-uploaded the theme and verified all files exist. Can anyone PLEASE look at http://cbclivehelp.com and tell me where I'm goofing up. I know it's an easy fix, but I'm not seeing it and I've been at it for 3 hours. Similar TutorialsDoes anyone know the code/script that is used for the image slider and the category switcher (where it says Our Games) as seen on http://en.popmog.com/games? I have no idea how to create something similar on my own site.
Hi, I've tried everything I can think of and can't get this script sorted out. So here I am :-) I have this script attached on my website now. I am working on a beta version and I need to have this script so that it doesn't affect the cookie for the live version. I've renamed everything I can see that can be and they each still affect each other. Any ideas? Thanks in advance. Kind regards, jo Code: function setActiveStyleSheet2(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } function getActiveStyleSheet2() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); } return null; } function getPreferredStyleSheet2() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") ) return a.getAttribute("title"); } return null; } function createCookie2(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie2(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } window.onload = function(e) { var cookie = readCookie2("style"); var title = cookie ? cookie : getPreferredStyleSheet2(); setActiveStyleSheet2(title); } window.onunload = function(e) { var title = getActiveStyleSheet2(); createCookie2("style", title, 365); } var cookie = readCookie2("style"); var title = cookie ? cookie : getPreferredStyleSheet2(); setActiveStyleSheet2(title); I have a stylesheet switcher which works fine in all mainstream browsers until Safari 5.1 and possibly a past version of Chrome. The source of the problem appears to be in WebKit version 534. Other designers have experienced similar problems: https://discussions.apple.com/thread...art=0&tstart=0 This version of WebKit appears not to action: Code: a.disabled = false in the following script. Code: function changeLayout(description){ var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++){ if(a.getAttribute("title") == description){a.disabled = false;} else if(a.getAttribute("title") != "default"){a.disabled = true;} } } (or perhaps it may be the case that it will only allow one active stylesheet, the default?) I have alternative code I can deliver to switch the stylesheet but it is more onerous and I only want to run it if the usual method would fail. Is there a way I could test if the browser is respecting "a.disabled = false" (or "true" for that matter) and then deliver the alternative code if not? OR is there a reliable way to test for WebKit version 534? Thanks in advance. Is it possible to do something like this: On a site there is a link that says "Darken Page". Upon clicking the link, the background color turns black. The link then changes to "Brighten things up" So just a style sheet switcher, but with one link and changes Thanks for any imput on this Hi, I am currently working on redoing my portfolio and I thought it would be great to use SiFR for some of my text, which I had working fine but somewhere along the line it stopped working. I have a horizontal menu at the top. All the links are made using SiFR. It was working great the day before yesterday but something I modified must've broken it because now the links are almost impossible to click on. They have a grey hover effect but it no longer is noticeable because it seems that something is blocking the links from working. You have to click like a madman to get anywhere. The only sub-page that I have up is 'PRINT DESIGN' and the menu is also not functioning on that page. Since this is my first time working with SiFR I am really lost as to how to fix this. Any help would be strongly appreciated. Thanks Kristin Hello, I have a xmlHttpRequest that was working in Internet explore 6,7 and now is broken in the new Internet explore 8. Can anyone help me pinpoint the problem here? The Error console says this. Invalid procedure call or argument: Code: req.base_open('get', ginf.host + '/includes/process.php?action=jstest&' + failures, true); Screen Captu http://i31.tinypic.com/2v81rg6.jpg This works in Firefox and the older Internet explorers. So I"m not sure what Microsoft did with Internet Exploder 8. Is there syntax error or something with it that the other browser ignored? What is wrong with it? This is the full javascript file if you like to look. http://pastebin.ca/1515445 Below are the full Javascript and HTML to detect a browser and either display HTML5 or Flash video. However, the script is returning an error, 'document.getElementById(...)' is null or not an object. Any suggestions? Code: var deviceAgent = navigator.userAgent.toLowerCase(); $brwzr = deviceAgent.match(/(chrome|firefox|safari|msie 9.0)/); if ($brwzr) { document.getElementById("video_5").setAttribute("class", "on"); } else { document.getElementById("video_F").setAttribute("class", "on"); } Code: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Video Switch</title> <script language="JavaScript" src="index/js/detect.js"></script> <style> <!-- .off { display: none; } .on { display: inline; } --> </style> </head> <body> <div id="video_5" class="off">HTML5!</div> <div id="video_F" class="off">Flash!</div> </body> </html> Hello everyone, I am sorry to take up your time, I need help with some small issues, I am not familiar with java / php. I will post my problems on different threads. --- N0 1 is: I need a image gallery like this: Big image is 540px wide and beneath it is a thumbnail that activates the big image on click. I have one now but I am not satisfied with it. The link is: http://sfantipa.ro/gal_iarna.html . What I do not like is the fact that it scales the vertical images as the same weight and distorts them and I want the thumbnails to be on 1 row with before and next < > buttons or scrolled by mouse over at the left and right row, doesnt really matter which one. The thumbnail will have some space between them but they will load them as they are not scale them to predefined w/h. No text description and the thumbnails are always displayed, not hide... I am asking here because although I found many scripts, none is the one I need Can anyone help please? Thanks fokes! Hi all, Did some searching but couldn't find anything to help me. I'm looking for a simple quiz script - basically, there would be an image on the screen (would be great if it was randomly generated out of maybe 100 different choices). The visitor would then click on one of two buttons (this is the "quiz" part) answering a question about the photo which was displayed. The script then tells the visitor if they got the answer right or wrong and then loads a new image for them to try again. It would be great if the script could keep a "streak counter" based on how many images a visitors got correct in a row. So for example: Question: is this a cat or a dog? [random image of dog or cat] [button to answer dog] [button to answer cat] Would this be fairly easy to implement (is there something like this already around) or is it more complicated than that? Thanks a bunch in advance for any help you can give. Hi all, Javascript is totally new to me and I am very frustrated. I have been trying to put together this ebay template and it's all set except I can't get my thumbnails to show the large image when you mouseover it! I believe my problem is that I don't have the <script type="text/javascript"> or <language=javascript> tag in the beginning of the template. Problem is im not sure if that's the prob or where to put it!! I tried putting it at the top and it made it so the whole template disappeared. I've tried putting it at various diff places and it messes the whole thing up. I'm lost! Please help! Here's the listing (sorry I would post just the part where there's an issue but I can't tell where that is! ) http://cgi.ebay.com/ws/eBayISAPI.dll...%3DI%26otn%3D2 Basically, I have a Simon Says game with very simple functions but I added an image map with buttons that I now want to use, rather than a table with images as buttons. The problem is, now I can't get the game to work with the image map. Can anyone help me?
I just need something that rotates/slides a few images when a page loads. I'd guess Jquery would work best? But it needs to work in all browsers, and I have read some horror stories about ones that don't. Any good recommendations?
I need help implementing what appears to be a simple javascript : http://www.javascriptkit.com/script/...ivviewer.shtml Quote: Directions: Add the below script to the HEAD section of your page: Code: <script src="DV.js" type="text/javascript"> /*********************************************** * Pagination Combo Box- by Axel Schneider (http://axelschneider.info/) * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more * Please keep this notice intact ***********************************************/ </script> <script type="text/javascript"> //Define your images using arbitrary variables, to be passed in as arguments later down the page: var bigbaby = '<img src="bigbaby.jpg" width="1075" height="717" border="0" alt="">' var pancake = '<img src="food1.jpg" width="300" height="375" border="0" alt="">' </script> <script src="DV.js" type="text/javascript"> /*********************************************** * Pagination Combo Box- by Axel Schneider (http://axelschneider.info/) * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more * Please keep this notice intact ***********************************************/ </script> <script type="text/javascript"> //Define your images using arbitrary variables, to be passed in as arguments later down the page: var bigbaby = '<img src="bigbaby.jpg" width="1075" height="717" border="0" alt="">' var pancake = '<img src="food1.jpg" width="300" height="375" border="0" alt="">' </script> <script src="DV.js" type="text/javascript"> /*********************************************** * Pagination Combo Box- by Axel Schneider (http://axelschneider.info/) * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more * Please keep this notice intact ***********************************************/ </script> <script type="text/javascript"> //Define your images using arbitrary variables, to be passed in as arguments later down the page: var bigbaby = '<img src="bigbaby.jpg" width="1075" height="717" border="0" alt="">' var pancake = '<img src="food1.jpg" width="300" height="375" border="0" alt="">' </script> <script src="DV.js" type="text/javascript"> /*********************************************** * Pagination Combo Box- by Axel Schneider (http://axelschneider.info/) * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more * Please keep this notice intact ***********************************************/ </script> <script type="text/javascript"> //Define your images using arbitrary variables, to be passed in as arguments later down the page: var bigbaby = '<img src="bigbaby.jpg" width="1075" height="717" border="0" alt="">' var pancake = '<img src="food1.jpg" width="300" height="375" border="0" alt="">' </script> You also need to download the below external JavaScript file: DV.js Then, to create a link that pops up an image when clicked on, do the following: Code: <a href="#" onClick="dv.showDV(pancake); return false">pancakes</a> Where pancake is the variable containing the image tag to be shown (see code in your HEAD section. Obviously this works on image links as well. I do not need a text link, I want the image to be displayed on a mouse click over the thumbail. I have tried to incorporate the HTML as follows : Code: <html> <head> <TITLE>Test</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <META NAME="Description" CONTENT="Test"> /*********************************************** * Pagination Combo Box- by Axel Schneider (h**p://axelschneider.info/) * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more * Please keep this notice intact ***********************************************/ </script> <script type="text/javascript"> //Define your images using arbitrary variables, to be passed in as arguments later down the page: var image = src="Images/SNICTI__Stationery_1_by_caprozo.jpg" width="2133" height="1600" border="0" alt="">' </script> </head> <body bgcolor="#000000" text="#000000"> <body bgcolor="#000000" vlink="#000000" alink="#0000FF" link="#000000"> <font size="3" face="Tahoma"> <div align="center"> <center> <p> <img src="Images/SNICTI__Stationery_1_by_caprozo_small.jpg" width="100" height="100" border="0"></p> </center> </div> </font> <p> </body> </html> Okay, I've already learned from google how to make the following two simple image galleries: This one displays a specific image when its link is clicked And this one displays the previous/next image for whatever's showing. (During its code, it points to this .js file.) My question is, how do I combine those two galleries? How can I make one gallery that contains both kinds of links? Since the two galleries were copied from different places, the names they use aren't the same, and I'm not sure what to change to make it all unified. (I tried fiddling with it for over an hour before giving up.) Let me know if you need any more info from me. Lets say I have two images in a box Code: <body> <div id="box"> <img src="image1.jpg" id="image1" width="100" height="100" /> <img src="image2.jpg" id="image2" width="100" height="100" /> </div> </body> When I click on Image1 I want Image2 to get replaced with a new image, called Image3. So I tried this code: Code: var image1 = document.getElementById("image1"); image1.onclick = image1_click (); function image1_click () { new_image= new Image new_image = document.getElementById("image2"); new_image.src="image3.jpg" } But instead of replacing the image on click, from some reason it replaces image2 with image3 from start/load. What should I do to make this work? Thank you. Hi, everyone. I've been scratching my head about what's wrong with my script for awhile now. What I need to do is use the swapImages(id1,id2,id3) function to simply swap three images at an interval of 2 seconds. What happens with my script is that the first image shows up, and after 2 seconds, it switches to the next one. The problem is that the images start rapidly switching infinitely after those first two seconds. Could someone point out where the problem spot in my code is? Here's the code from my external js file: Code: function swapIt(id1,id2,id3) { var object1 = document.getElementById(id1); var object2 = document.getElementById(id2); var object3 = document.getElementById(id3); var z1 = object1.style.zIndex; var z2 = object2.style.zIndex; var z3 = object3.style.zIndex; object1.style.zIndex = z3; object2.style.zIndex = z1; object3.style.zIndex = z2; } Here's the code invoking this function in my html file: Code: function moveAvalon() { var x = xCoord("avalon"); if(x <= (W - 125)) { shiftIt("avalon", 10, 0); setInterval("moveAvalon()", 50); } else if(x > (W - 125)) { swapImages(); } } function swapImages() { showIt("kids"); showIt("fiction"); showIt("nfiction"); setInterval( 'swapIt("kids", "fiction", "nfiction")' , 2000); } Hi there, I'm having some real trouble with what I thought would be some really simple animations. I've been using, or trying to use the jQuery plugin. Basically I have a button, the mark up would probably (don't have to if anyone can come up with something better) look like this: Code: <button><span>Text in Button</span><i></i></button> I've uploaded a pic, to show (very crudely), how the animation should work: So, you have text with circle graphic on the end by default. When you hover over this element, the background should slide across. This could use another image, probably preferably, so 2 in totally, one for the left side and one for the right. As well as this animation,the text should also slide, probably just 5/10px or so across. I guess this would all animate in reverse when moving the mouse off the element. Does anyone have any ideas on this or can point me in the right direction? It would be greatly appreciated as ever. Thanks for taking the time to read, Steve I am asking a pretty simple question, but you got to start learning somewhere, you know! Anyway, I have implemented a script that resizes images into small thumbs on the left side of a page and shows the full size image on the right when the user click on a thumb. It works well. However, I have a possible 10 thumbs on theleft and my database that feeds this does not always have 10 images. Since I re-use the page for mutiple listings, I need to find a way to disable the broken image link for listings that don't have 10 thumbs. I have attached a picture of what it looks like. Here is the script: Code: #jgal { list-style: none; width: 200px; } #jgal li { opacity: .5; float:left; display: block; height:60px; width:60px; overflow:hidden; background-position: 50% 50%; cursor: pointer; border: 3px solid #fff; outline: 1px solid #ddd; margin-right: 14px; margin-bottom: 14px; } #jgal li img { height:60px; width:auto; } #jgal li.active img { display: block; } #jgal li.active, #jgal li:hover { outline-color: #bbb; opacity: .99 /* safari bug */ } /* styling without javascript */ #gallery { list-style: none; display: block; } #gallery li { float: left; margin: 0 10px 10px 0; } </style> <!--[if lt IE 8]> <style media="screen,projection" type="text/css"> #jgal li { filter: alpha(opacity=50); } #jgal li.active, #jgal li:hover { filter: alpha(opacity=100); } </style> <![endif]--> <script type="text/javascript">document.write("<style type='text/css'> #gallery { display: none; } </style>");</script> <!--[if lt IE 6]><style media="screen,projection" type="text/css">#gallery { display: block; }</style><![endif]--> <script type="text/javascript"> var gal = { init : function() { if (!document.getElementById || !document.createElement || !document.appendChild) return false; if (document.getElementById('gallery')) document.getElementById('gallery').id = 'jgal'; var li = document.getElementById('jgal').getElementsByTagName('li'); enlargedImg = document.createElement('img'); document.getElementById('jgal').parentNode.insertBefore(enlargedImg,document.getElementById('jgal').nextSibling); enlargedImg.src = li[0].getElementsByTagName('img')[0].src; li[0].className = 'active'; for (i=0; i<li.length; i++) { li[i].style.backgroundImage = 'url(' + li[i].getElementsByTagName('img')[0].src + ')'; li[i].style.backgroundRepeat = 'no-repeat'; li[i].title = li[i].getElementsByTagName('img')[0].alt; gal.addEvent(li[i],'click',function() { var im = document.getElementById('jgal').getElementsByTagName('li'); for (j=0; j<im.length; j++) { im[j].className = ''; } this.className = 'active'; enlargedImg.src = this.getElementsByTagName('img')[0].src; }); } }, addEvent : function(obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent("on"+type, obj[type+fn]); } } } gal.addEvent(window,'load', function() { gal.init(); }); And then my list basically looks like this: Code: <ul id="gallery"> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb5']; ?>" alt="<?php echo $row_WADAitems['ItemDesc5']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb6']; ?>" alt="<?php echo $row_WADAitems['ItemDesc6']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb7']; ?>" alt="<?php echo $row_WADAitems['ItemDesc7']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb8']; ?>" alt="<?php echo $row_WADAitems['ItemDesc8']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb9']; ?>" alt="<?php echo $row_WADAitems['ItemDesc9']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb10']; ?>" alt="<?php echo $row_WADAitems['ItemDesc10']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb11']; ?>" alt="<?php echo $row_WADAitems['ItemDesc11']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb12']; ?>" alt="<?php echo $row_WADAitems['ItemDesc12']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb13']; ?>" alt="<?php echo $row_WADAitems['ItemDesc13']; ?>"></li> <li><img src="images/details/<?php echo $row_WADAitems['ItemThumb14']; ?>" alt="<?php echo $row_WADAitems['ItemDesc14']; ?>"></li> </ul> So as you can see, if I don't have an image in the database that it pulls from, I get that icon for a broken image link. How can I remove that icon so it doesn't show the no image icon? Many thanks! Hi, I'm have set up a gallery site, pretty standard stuff with thumbnails to the right and big image to the left. I would like to add a fade in on the big image when the thumbnail is clicked and don't really know how to implement it. The big images are contained in a div called <#left> while the thumbs are within a div called <div class="gallery"> I have searched Google and these forums for a solution but haven't had any luck...can anyone help me out with this? Thanks J I imagine this would be very simple for someone who knows javascript. I want to have three fields. First field is "posted speed limit", second field is "actual speed" and third field will be the output field. All the script needs to do it subtract the posted speed from the actual speed and add a ZERO to the end; which is the amount of the speeding ticket. The minimum fine is $100, however. So, 5 miles over the speed limit would be $100 (minimum value) 15 miles over the speed limit would be $150 (add a zero) 35 miles over the speed limit would be $350. etc. I know very little Javascript, if anyone could help me out with this, I'd appreciate it. Thanks, Sean |