JavaScript - Images Are Broken
Code:
<body> <center> <script type="text/javascript"> var imageSrc = ['<img www.mysite.com/subfolder/001.jpg></img>','002.jpg','003.jpg', '004.jpg','005.jpg','006.jpg']; var imageSrc2 = [];; function copyRandom(){ if (0 == imageSrc2.length) { imageSrc2 = imageSrc.concat(); } var randNum = (Math.random()*imageSrc2.length) | 0; return imageSrc2.splice(randNum, 1); } </script> <!-- <button onclick="document.getElementById('xx').innerHTML = (copyRandom());"> --> <button onclick="document.getElementById('xx').innerHTML = (copyRandom());"> Draw A Card </button> <div id="xx"></div> <!-- <div id="xx"></div> --> </center> </body> Why are my images broken in this script? Specifically "<img www.mysite.com/subfolder/001.jpg></img>" as the rest are just placeholders until I solve the first one. Similar TutorialsThe latest version of MSIE fails to read the value of a popup menu in a form that I have. It worked fine in a previous version, and works in Firefox and Mac Safari. Here is an edited version of what I have: Code: var d = null; function myTest(){ alert("mWunits value = ".concat(d.mWunits.value)) } . . . <body onload="d = document.forms[0];"> . . . <form onsubmit="return false" > <table align="center" border="0"> <tbody> <tr> <td align="right">Conductor Size (d):</td> <td><input name="ef_dw" size="12"> </td> <td align="left"> <select name="mWunits" size="1"> <option selected="selected">mm</option> <option>AWG</option> </select> </td> </tr> . . . The popup name is mWunits, and should have either "AWG" or "mm" as a value. And the function myTest() should display that value. However the value is an empty string. There is another popup in the same form, and it exhibits the same problem. My script reads the values of regular input fields just fine. As I said, this used to work under earlier MSIE versions, and works in other browsers. Has something been deprecated that I don't know about? I've got a style control for my website where the user can select text color and background color. Cookies then remember the selections. The problem I have is when you select a text color the background color is changed instead of the text color. After page refresh both the text and background colors are correct. The error console reports a few errors in each js script. The errors all say 'sel is undefined' on line 7. html: Code: <!DOCTYPE html> <html lang="en"> <head> <title>Style Control</title> </head> <body> <p><b>Style Control</b></p> <p>Text color: (Broke - Sets bg color insted, works after page refresh)</p> <form onsubmit="return false;" action=""> <script type="text/javascript" language="JavaScript" src="text_color.js"></script> <select name="color_select1" size="1" onchange="return setColor(this, global_name1)"> <option style="background-color: white;" value="white">white</option> <option style="background-color: black; color: white;" value="black">black</option> <option style="background-color: seagreen;" value="seagreen">seagreen</option> <option style="background-color: springgreen;" value="springgreen">springgreen</option> <option style="background-color: royalblue;" value="royalblue">royalblue</option> <option style="background-color: skyblue;" value="skyblue">skyblue</option> </select> </form> <br /><br /> <p>Background color:</p> <form onsubmit="return false;" action=""> <script type="text/javascript" language="JavaScript" src="bg_color.js"></script> <select name="color_select2" size="1" onchange="return setColor(this, global_name2)"> <option style="background-color: white;" value="white">white</option> <option style="background-color: black; color: white;" value="black">black</option> <option style="background-color: seagreen;" value="seagreen">seagreen</option> <option style="background-color: springgreen;" value="springgreen">springgreen</option> <option style="background-color: royalblue;" value="royalblue">royalblue</option> <option style="background-color: skyblue;" value="skyblue">skyblue</option> </select> </form> </body> </html> </body> </html> text_color.js : Code: var global_name1 = 'tcolor'; // function getColor(sel, cookie_name) { var cookie_value = getCookie(cookie_name); if (!cookie_value) cookie_value = 'black'; document.body.style.color = cookie_value; var opt = sel.options; var x, len = sel.length; for (x=0; x<len; x++) { if (opt[x].value == cookie_value) { opt[x].selected = true; break; } } return true; } getColor(document.forms[0].color_select1, global_name1); // function setColor(sel, cookie_name) { var opt = sel.options[sel.selectedIndex].value; var oneDay = 24 * 60 * 60 * 1000; var oneYear = 365 * oneDay; var expDate = new Date(); expDate.setTime(expDate.getTime() + oneYear); setCookie(cookie_name, opt, expDate); return getColor(sel, cookie_name); } // ---------------------------------------- // function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function setCookie(name, value) { var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function delCookie(name) { exp = new Date(); exp.setTime(exp.getTime() - (24*60*60*1000)); var cval = getCookie(name); cval = (cval == null) ? "" : cval; document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } bg_color.js : Code: var global_name2 = 'bgcolor'; // function getColor(sel, cookie_name) { var cookie_value = getCookie(cookie_name); if (!cookie_value) cookie_value = 'white'; document.body.style.backgroundColor = cookie_value; var opt = sel.options; var x, len = sel.length; for (x=0; x<len; x++) { if (opt[x].value == cookie_value) { opt[x].selected = true; break; } } return true; } getColor(document.forms[0].color_select2, global_name2); // function setColor(sel, cookie_name) { var opt = sel.options[sel.selectedIndex].value; var oneDay = 24 * 60 * 60 * 1000; var oneYear = 365 * oneDay; var expDate = new Date(); expDate.setTime(expDate.getTime() + oneYear); setCookie(cookie_name, opt, expDate); return getColor(sel, cookie_name); } // ---------------------------------------- // function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function setCookie(name, value) { var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function delCookie(name) { exp = new Date(); exp.setTime(exp.getTime() - (24*60*60*1000)); var cval = getCookie(name); cval = (cval == null) ? "" : cval; document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } Many thanks for any help. Strings,, Broken Links, and Variables --HELP! I have a page with over 600 lines of code that I need to fix, the problem is as such: The page contains about 200 links, the problem is that the link tags are all messed up,, instead of the URL's they all got replaced with xxxxx so instead of: <a href="http://mystore.com/product1">product1</a> it would read: <a href="http://mystore.com/xxxx">product1</a> each product has to link to it's own page .... i.e: product1 goes to /mystore.com/product1,,, and so on I need help writing a script or performing some sort of function, that will take the text in between the <a></a> tags and insert it into it's own tag instead of the xxxxx so it would see <a href="http://mystore.com/xxxx">BaseBall Gloves</a> and convert that line into <a href="http://mystore.com/BaseBall%20Gloves>BaseBall Gloves</a> -- OUTPUTS: the ideal way would be if it could replace the existing source (kind of how you can do a find and replace),, if that's not possible, it would need to output all the existing source code with the modified <a> tags to a new window, and then I can copy that code into a new page. I've tried using regular expressions and different functions but can't get it to work. I really appreciate your help.. Thanks. A common javascript function that capitalizes input as user types (onkeypress) no longer works as of IE9. Need a function that also works in IE 9 that doesn't not change method call or interface (as it's used in 150 places throughout application). CALL: [CODE] el.onkeypress = function(el) { return c_capitalizeInput(el); } [CODE] FUNCTION: [CODE] // Intercepts keyboard input and capitalizes keystrokes. // Call with onkeypress="return capitalizeInput(event);" // Compatible with both IE and Netscape/Mozilla function c_capitalizeInput(evt) { evt = (evt) ? evt : ((window.event) ? window.event : ""); if (window.event) { // IE if ((evt.keyCode >= 97) && (evt.keyCode <= 122)) { evt.keyCode = evt.keyCode - 32; } return true; } else if (evt.which) { // Netscape and Mozilla key = evt.which; if ((key >= 97) && (key <= 122)) { key = key - 32; evt.target.value = evt.target.value + String.fromCharCode(key); return false; } return true; } else { return true; // Can't do anything for other browsers } } [CODE] Any suggestions to make this work in IE9? I have been modifying this form: http://www.kartaway.com.au/form.html to be part of an iPhone optimized site for the same client. The modified form works, however it no longer stops emails being sent that do not have the required fields filled in. The modified form is he http://marketingandbranding.com.au/itest/icontact.html The original is built using a table which I have removed and replaced with divs. Didn't think I'd left anything out which would matter but I guess I must have. Please help, i don't really know any JavaScript except what I copy and paste. Hey friends, I'm not sure where to post this, so redirect me if there is a more appropriate location, please. I am having a very strange problem with a javascript gallery contained within a site I am working on. The problem is, that it broke (appears to be a non-working javascript) while transferring servers (from test server to client server). It makes me believe that it is a filepath problem, but I have checked over the filepaths, the javascript, the css, the html, substituted the new files back into the test server one by one, which, all work on the test server (and vice versa, the old files dont work on the new server)... and cannot seem to find the problem. I am using noobSlide gallery and have replaced the JS files incase they became corrupted in any way during the transfer. The website is located he http://www.design-evolve.com The gallery is located within Landscape-> Residential Landscape (under the Projects section). Once you reach the Residential Landscape, the Gallery is at the top of the page, and the arrows *should* scroll you through 5 images. Can anyone give me a fresh set of eyes to see if I am overlooking something? Any help would be much appreciated. Thanks, -Andrew Hi All, I am working on a script that creates a table, taking the data from a number of text fields and populating the table cells with it. Originally I had to start with an existing table containing one blank row but I was able to get the script to create the table dynamically. Unfortunately I seem to have broken my delete row function (this was working fine when the script started with an existing table). The error I am getting is: TypeError: 'cells.0.childNodes' is null or not an object I googled this but could not find anything to help. I don't have alot of javascript experience and need help from the experts. Thanks in advance for all your help guys! Kind regards, Ken 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> </style> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <SCRIPT language="javascript"> function addRow(tableID) { if (!document.getElementById(tableID)) { //alert("the table does not exist"); var body = document.getElementsByTagName("body")[0]; // creates a <table> element and a <tbody> element var tbl = document.createElement("table"); var tblBody = document.createElement("tbody"); var newRow = document.createElement("tr"); // add the row to the end of the table body tblBody.appendChild(newRow); // put the <tbody> in the <table> tbl.appendChild(tblBody); // appends <table> into <body> body.appendChild(tbl); // sets the id of "dataTable" and border attribute of tbl to 0; tbl.setAttribute("id", "dataTable"); tbl.setAttribute("border", "0"); } var StartTime = document.getElementById('StartTime'); var EndTime = document.getElementById('EndTime'); var MaterialID = document.getElementById('MaterialID'); var Title = document.getElementById('Title'); var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "checkbox"; cell1.appendChild(element1); var cell2 = row.insertCell(1); var element2 = document.createElement("input"); element2.type = "text"; element2.setAttribute("name","StartTime[]"); element2.value = StartTime.value; cell2.appendChild(element2); StartTime.value=""; var cell3 = row.insertCell(2); var element3 = document.createElement("input"); element3.type = "text"; element3.setAttribute("name","EndTime[]"); element3.value = EndTime.value; cell3.appendChild(element3); EndTime.value=""; var cell4 = row.insertCell(3); var element4 = document.createElement("input"); element4.type = "text"; element4.setAttribute("name","MaterialID[]"); element4.value = MaterialID.value; cell4.appendChild(element4); MaterialID.value=""; var cell5 = row.insertCell(4); var element5 = document.createElement("input"); element5.type = "text"; element5.setAttribute("name","Title[]"); element5.value = Title.value; cell5.appendChild(element5); Title.value=""; } function deleteRow(tableID) { if (document.getElementById(tableID)) { //alert("the table exists"); try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { table.deleteRow(i); rowCount--; i--; } } }catch(e) { alert(e); } } } </SCRIPT> <body> <span id="spryStartTime"> <label for="StartTime">Start Time:</label><br /> <input name="StartTime" type="text" id="StartTime" tabindex="1" size="10" maxlength="8" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><br /> <label for="EndTime">End Time:</label><br /> <span id="spryEndTime"> <input name="EndTime" type="text" id="EndTime" tabindex="2" size="10" maxlength="8" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><br /> <label for="MaterialID">Material ID:</label><br /> <span id="spryMaterialID"> <input name="MaterialID" type="text" id="MaterialID" tabindex="3" size="10" maxlength="10" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /> <label for="Title">Title:</label><br /> <span id="spryTitle"> <input name="Title" type="text" id="Title" tabindex="4" size="50" maxlength="50" /> <span class="textfieldRequiredMsg">A value is required.</span></span><br /> <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /> <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" /> <script type="text/javascript" /> var sprytextfield3 = new Spry.Widget.ValidationTextField("spryStartTime", "time", {validateOn:["blur"], format:"HH:mm:ss", useCharacterMasking:true}); var sprytextfield4 = new Spry.Widget.ValidationTextField("spryEndTime", "time", {format:"HH:mm:ss", useCharacterMasking:true, validateOn:["blur"]}); var sprytextfield5 = new Spry.Widget.ValidationTextField("spryMaterialID", "none", {validateOn:["blur"]}); var sprytextfield6 = new Spry.Widget.ValidationTextField("spryTitle", "none", {validateOn:["blur"]}); </script> </body> </html> I have created a program that works great but sometimes it does not finish. It is the exact same as the one we see in this forum when you want to insert an image into a forum post. The program takes in a users image url through prompt, then regenerates the information within the textbox with [img] tags. The problem is I try to do this once and it will work great, but then I will try it again and fill out all of the information the exact same way and nothing happens. By nothing happens I mean after I hit enter the text box will remain empty with no regenerated code. But if I do a page refresh it works. That leads me to believe there is nothing wrong with my code b/c I do it once and get a sound result, then again and get nothing. Anyone have any experience with broken programs like this before or any words of advice? PHP Code: <script language="javascript"> function imgGenerator(){ var question=confirm("Share a Picture?"); if (question==true){ var obj=document.getElementById("mngl-board-post-input"); var imgurl = prompt('To Share an image paste the image url here \nSupport .jpg .jpeg .gif .bmp and .png'); if (imgurl == "" || imgurl == null) {return false;} var txt=document.createTextNode("[a][img]"+imgurl+"[/img][/a]"); obj.appendChild(txt); } else {} } </script> PHP Code: <a href="javascript:void(0);" onClick="imgGenerator();"><img src="http://instride.org/images/image.png" alt="Share an Image" /></a> Hi Guys, This isn't the first time I've posted about cookies, and I apologize for that. My cookies were working perfectly until I made some changes to the site (ie. ran it through w3 validation). Now they aren't writing. I can't find any bugs with firebug, and I've tried following it through line by line. I expect my email validation is returning false, and I would really appreciate if you can help me find the bug. Here's the code, which I call with onsubmit="return Getvalue()" The rest of the page is at www.saverally.com Code: function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } function ValidateForm(emailID){ //var emailID=document.frmSample.txtEmail if ((emailID.value==null)||(emailID.value=="")){ showDialog('Uh-oh.','Our tech-pigeons say you must enter an email address.','success',3); emailID.focus() return false } if (echeck(emailID.value)==false){ emailID.value="" showDialog('Uh-oh.','Our tech-pigeons say you must enter a "proper" email address.','success',3); emailID.focus(); return false } return true } /*Email Validation*/ function Getvalue() { var validation=ValidateForm(document.getElementById("email")); if(validation==true) { user_email=document.getElementById("email").value; createCookie("userEmail",user_email,365); document.addform.submit(); return true; } else { return false; } } </script> Hi there, I've been searching for an answer to this for the last few days but with no luck, so I thought I'd register here to see if anyone can possibly help. All I've been able to find everywhere for this is examples of changing images when rolling over them or clicking them, and I don't need that. What I need is a bit of javascript that will recognise some image paths on a page and replace those image paths with other ones. It's for an ecommerce website on a certain platform, using a customer reviews section which outputs star images based on the customer's rating. So, the images used (which look awful) are, for example, "sourcehere/stars_5.gif", "sourcehere//stars_4.gif", and so on. Just 5 of them. I want to design my own 5 images, upload those images, and then have the javascript replace the rubbish looking ones on the page with my own images. I thought I'd be able to find something quite easily, but so far all I can find is examples of mouseover events and so on, and I don't need any of that, just the entire image replaced with my own image. Can anyone help please? I'm a beginner with javascript so I'll need it spelled out to me! Thankyou for your time. Hey everyone! I'm in the process of creating a portfolio site for my artwork and I'm requesting help. The website has a scalable JQuery background which changes depending on which thumbnail you click. I've uploaded the progress he http://www.aldousmassie.com/newprogress I'm using this code at the moment to scroll through the background: Code: <!-- SCRIPT FOR CHANGING BG ON CLICK --> <script type="text/javascript"> imgs=Array("img/00.jpg","img/01.jpg","img/02.jpg","img/03.jpg"); var x=0; function change() { document.getElementById("bgimg").src=imgs[++x]; if (x==3) { x=-1; } } if (!imgs[x+1]) { x=-1; } </script> <!-- SCRIPT BELOW OVERWRITES SCRIPT ABOVE --> <script type="text/javascript"> imgs=Array("img/08.jpg","img/09.jpg","img/10.jpg","img/11.jpg","img/12.jpg","img/13.jpg"); var x=0; function change() { document.getElementById("bgimg").src=imgs[++x]; if (x==5) { x=-1; } } if (!imgs[x+1]) { x=-1; } </script> Unfortunately, the bottom code overwrites the top. Is it possible for each different background image to have their own "set" of images that could be scrolled through onclick? I'd appreciate any tips that point me in the right direction. Thank you. Please help have a look at the scripts... Where's gone wrong that whenever an image fades out into 0, it reappears before another image comes out? I've wanted to make the image disappear shortly before a new image is loaded. I've worked on this and played around with the scripts, yet no finding... Please do tell me if you know the answer to it. Thanks. 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> window.onload = function(){ var pic = document.getElementById("pic"); document.getElementById("nextImageFading_btn").onclick = function(){nextImageFading();} } var img = new Array(); img[0] = "http://www.blogsdna.com/wp-content/uploads/2011/03/Google-labs.png"; img[1] = "http://thenextweb.com/socialmedia/files/2010/07/youtube_logo.png"; img[2] = "http://www.techlifeweb.com/facebook_logo.jpg"; img[3] = "http://hackingarticles.com/wp-content/uploads/gmail_logo_stylized.png"; var o = 100; var t; var p = 0; var f = 1; function nextImageFading(){ t = setInterval( function(){ pic.src = img[p]; pic.style.filter = "alpha(opacity="+o+")"; pic.style.MozOpacity = o/100; pic.style.opacity = o/100; o -= 1; if(o<=0){ clearInterval(t); if(p<img.length-1){ p = p+1; } else {p=0;} pic.src = img[p]; pic.style.filter = "alpha(opacity=100)"; pic.style.MozOpacity = 1; pic.style.opacity = 1; o = 100; } },f); } </script> </head> <body> <img id="pic" src="" style="width:400px; height:400px;" /> <br style="clear:both;" /> <a id="nextImageFading_btn" href="#">NEXT</a> </body> </html> Good afternoon I am trying to make a form and keep getting stuck on one thing, don't know if JavaScript is the way to go so any advise would be helpful. basicly i have a form giftcert.html -that has text input boxes the user fills in and a link to the next page for the user to pick a gift card giftcards.asp -the user picks a gift card by radio buttons (over 100)grouped by name and then pushes a button to take them to the next page passing the value of the radio and image (here is the issue) giftcert.asp -this page displays the text boxes from the first page with the value already present (used asp to achieve) and the value of the radio button (a stock number - used asp to achieve) and i want a sample of the image attached to the stock number. how do i pass the image attached to the radio button from giftcards.asp to giftcert.asp i don't know where i am going wrong a) how do i attach the image to the button do i use an onclick="pass src" and how b) how do i get the image to show up in giftcert.asp if the elements have name attributes with the same value, according to legacy DOM, it will return an array of those elements if you access the name property of 'document'. However, this doesn't apply to img elements. If the HTML code is as follows: Code: <img src="img/a.jpg" name="pic" /><img src="img/b.jpg" name="pic" /> <form name="pic">a</form> <form name="pic">b</form> then document.forms["pic"] (return an array) <-- as expected document["pic"] or document.pic (return an array) <-- as expected document.images["pic"] : in IE -- it returns the last image in FF -- it returns the first image ~~OMG~~ any idea? thx in advance. Hi i have created a scrolling gallery using javascript but i am having trouble aligning my images. right now they are in the center of the page but at the bottom, but i want them on top of the page. here is my code. <html> <head> <title>Gallery</title> <link href="website.css" rel="stylesheet" type="text/css"> <left> <table border="0" width="50" height="200"> <tr><td><a href="unique sports.html"><img width="400" height="230" align="center" src="unique sports logo.gif" border="0"></td></tr> <tr><td><a href="unique sports.html"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/home button.gif" border="0"><a/></td></tr> <tr><td><a href="about us.html"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/about us.gif" border="0"></a> </td></tr> <tr><td><a href="http://youtube.com"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/reviews.gif" border="0"></a> </td></tr> <tr><td><a href="Contact us.html"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/contact us button.gif" border="0"></a></td></tr> </td></tr> <tr><td><a href="shop section.html"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/shop section .gif" border="0"></td></tr> <tr><td><a/><a href="http://google.com"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/latest news .gif" border="0"></a></td></tr> <tr><td><a href="http://youtube.com"><img src="/home/yatkin/Desktop/Uni work/Muti apps design/photo gallery .gif" border="0"></a></td></tr> </table> <center> <table> <td> <script language="JavaScript1.2"> var scrollerwidth='500px' var scrollerheight='500px' var pausebetweenimages=3000 var slideimages=new Array() slideimages[0]='<img src="72757631_9c35b8eff2_o.jpg">' slideimages[1]='<img src="363507907_FEDxk-L.jpg">' slideimages[2]='<img src="2542265127_6108971aa4.jpg">' slideimages[3]='<img src="2795508357_66b1cea812.jpg">' var ie=document.all var dom=document.getElementById if (slideimages.length>2) i=2 else i=0 function move1(whichlayer){ tlayer=eval(whichlayer) if (tlayer.top>0&&tlayer.top<=5){ tlayer.top=0 setTimeout("move1(tlayer)",pausebetweenimages) setTimeout("move2(document.main.document.second)",pausebetweenimages) return } if (tlayer.top>=tlayer.document.height*-1){ tlayer.top-=5 setTimeout("move1(tlayer)",50) } else{ tlayer.top=parseInt(scrollerheight) tlayer.document.write(slideimages[i]) tlayer.document.close() if (i==slideimages.length-1) i=0 else i++ } } function move2(whichlayer){ tlayer2=eval(whichlayer) if (tlayer2.top>0&&tlayer2.top<=5){ tlayer2.top=0 setTimeout("move2(tlayer2)",pausebetweenimages) setTimeout("move1(document.main.document.first)",pausebetweenimages) return } if (tlayer2.top>=tlayer2.document.height*-1){ tlayer2.top-=5 setTimeout("move2(tlayer2)",50) } else{ tlayer2.top=parseInt(scrollerheight) tlayer2.document.write(slideimages[i]) tlayer2.document.close() if (i==slideimages.length-1) i=0 else i++ } } function move3(whichdiv){ tdiv=eval(whichdiv) if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){ tdiv.style.top=0+"px" setTimeout("move3(tdiv)",pausebetweenimages) setTimeout("move4(second2_obj)",pausebetweenimages) return } if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){ tdiv.style.top=parseInt(tdiv.style.top)-5+"px" setTimeout("move3(tdiv)",50) } else{ tdiv.style.top=scrollerheight tdiv.innerHTML=slideimages[i] if (i==slideimages.length-1) i=0 else i++ } } function move4(whichdiv){ tdiv2=eval(whichdiv) if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){ tdiv2.style.top=0+"px" setTimeout("move4(tdiv2)",pausebetweenimages) setTimeout("move3(first2_obj)",pausebetweenimages) return } if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){ tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px" setTimeout("move4(second2_obj)",50) } else{ tdiv2.style.top=scrollerheight tdiv2.innerHTML=slideimages[i] if (i==slideimages.length-1) i=0 else i++ } } function startscroll(){ if (ie||dom){ first2_obj=ie? first2 : document.getElementById("first2") second2_obj=ie? second2 : document.getElementById("second2") move3(first2_obj) second2_obj.style.top=scrollerheight second2_obj.style.visibility='visible' } else if (document.layers){ document.main.visibility='show' move1(document.main.document.first) document.main.document.second.top=parseInt(scrollerheight)+5 document.main.document.second.visibility='show' } } window.onload=startscroll </script> <ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; visibility=hide> <layer id="first" left=0 top=1 width=&{scrollerwidth};> <script language="JavaScript1.2"> if (document.layers) document.write(slideimages[0]) </script> </layer> <layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide> <script language="JavaScript1.2"> if (document.layers) document.write(slideimages[dyndetermine=(slideimages.length==1)? 0 : 1]) </script> </layer> </ilayer> <script language="JavaScript1.2"> if (ie||dom){ document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;">') document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">') document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">') document.write(slideimages[0]) document.writeln('</div>') document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">') document.write(slideimages[dyndetermine=(slideimages.length==1)? 0 : 1]) document.writeln('</div>') document.writeln('</div>') document.writeln('</div>') } </script> </td> </tr> </table> </head> <body> </body> </html> Thank you Hi! I've seen several sites that use what looks like the alert function (I know it isn't), where the site gets darkened and a popup box (similar to that of the alert one) comes up and displays an image (and only an image) ... how is this done? Regards Matthew Hi, I'm trying to put a script in my code which when an image is clicked in the webpage, i'd like it to go through the array from index 0,1,2,3, displaying the images as the current picture is clicked. Once at the end of the array, i'd like it to return to the first index (0) and do the same again. In effect, i'm trying to create a gallery of images for users to click through. I have this code, now it loads up fine, the first image loads, when I click the image, the image in index[1] loads, but when clicked again, it returns to index[0] then the same happens over and over. My code: Code: <script type="text/javascript"> var myImages = new Array() myImages[0] = 'images/homePic.png'; myImages[1] = 'images/pinkWall.png'; myImages[2] = 'images/wendy.png'; myImages[3] = 'images/horizon.png'; function imgChange(that) { var index = 0; while (that.src.indexOf(myImages[index]) != -1) { myImages[index] = myImages[index++]; } that.src = myImages[index]; return false; } </script> HTML: Code: <img src="images/homePic.png" id="pic" alt="homePic" name="bGarden" height="344px" width="490px" onclick="return imgChange(this)" /> Any advice will be greatly appreciated, thank you. Hi I am currently doing a photography site. I would like to do a 'portfolio' page, but would like to pre-load the images so that they appear on-screen faster. Do I need to connect code to <body onload>? Hello, all. I have a common problem, but despite my research I have been unable to find a solution that works for my situation. I have a large image and several thumbnails below it. I am working with a content management system, so I am able to edit the output of the anchor text around the image, the divs around the image, but NOT the actual image string itself. The images do have some classes built into them, but no IDs. Anyways, I want the main image source to change based on the href of the thumbnail below. So if you click on any one of the thumbs, the href for that thumbnail populates as the source for the main image. Here is my code so far: Code: <div class="images" id="big-image"> <a href="dianaminiflash_shop0001-11.jpg"> <img width="500" height="500" src="dianaminiflash_shop0001-11-500x500.jpg" class="attachment-shop_single wp-post-image" /></a> <div class="thumbnails"> <a href="dianamini_en-rose_front1.jpg" title="dianamini_en-rose_front" rel="thumbnails" class="product-thumb first"> <img src="dianamini_en-rose_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> <a href="diana-mini_fern-green_front1.jpg" class="product-thumb "> <imgsrc="diana-mini_fern-green_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> <a href="diana-mini_flashkit_white_front1.jpg" class="product-thumb last"> <img src="diana-mini_flashkit_white_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> </div> </div> One of the things I've tried that has not worked but has been offered up as a solution on this forum and others is: Code: $(".thumbnails a").click( function() { var changeSrc = $(this).attr("href"); $(".attachment-shop_single").attr("src", changeSrc); return false; }); Any suggestions on what I'm doing wrong here? I really appreciate the help in advance. Hi, I tried displaying few images as MENU using Javascript. These images are showed normally in Firefox and chrome except Internet Explorer. Help plz
|