JavaScript - Add Links In Easyslide Images (javascript)?
Hey
Im trying to add links in the images for EasySlide but I cant see to see where to put it..... Here is the .js code: Code: /** * @author Bruno Bornsztein <bruno@missingmethod.com> * @copyright 2007 Curbly LLC * @package Glider * @license MIT * @url http://www.missingmethod.com/projects/glider/ * @version 0.0.3 * @dependencies prototype.js 1.5.1+, effects.js */ /* Thanks to Andrew Dupont for refactoring help and code cleanup - http://andrewdupont.net/ */ Glider = Class.create(); Object.extend(Object.extend(Glider.prototype, Abstract.prototype), { initialize: function(wrapper, options){ this.handStopped = false; this.animating = false; this.wrapper = $(wrapper); this.scroller = this.wrapper.down('div.scroller'); this.contentDiv = this.scroller.down('div'); this.current = $(this.contentDiv.children[0].id); this.sectionWidth = this.contentDiv.children[0].getWidth(); this.slideRelations = {}; this.options = Object.extend({ effectType: 'mosaic', duration: 3.0, frequency: 3, eRows: Prototype.Browser.IE ? 3 : 6, eCols: Prototype.Browser.IE ? 6 : 12, eColor: '#FFFFFF' }, options || {}); this.effects = { 'scroll' : this.scroll, 'speedscroll' : this.speedscroll, 'fade' : this.fade, 'blend' : this.blend, 'mosaic' : this.mosaic }; this.sections = this.wrapper.getElementsBySelector('div.section'); for (var i = 0; i < this.sections.length; i++) { var nextSibling = this.sections[i].nextSiblings()[0]; if (nextSibling){ this.slideRelations[this.sections[i].id] = nextSibling.id; } else { this.slideRelations[this.sections[i].id] = this.sections[0].id; } this.effects[this.options.effectType].bind(this)().prepare(this.sections[i], i); } this.events = { mouseover: this.pause.bind(this), mouseout: this.resume.bind(this) }; this.addObservers(); if (this.options.autoGlide) { this.start(); } else { this.handStopped = true; } }, scroll: function() { var glider = this; return { prepa function(el, i) { if (i > 0) { $(el).setStyle('left: ' + glider.sectionWidth + 'px;'); } else { glider.toggleControl($$('a[href="#' + el.id + '"]')[0]); } }, animate: function(elementIdToShow, direction) { $(elementIdToShow).setStyle('left: ' + (direction === 'normal' ? glider.sectionWidth : -glider.sectionWidth) + 'px;'); new Effect.Parallel([ new Effect.Move(elementIdToShow, { sync: true, x: 0, y: 0, mode: 'absolute' }), new Effect.Move(glider.current.id, { sync: true, x: direction === 'normal' ? -glider.sectionWidth : glider.sectionWidth, y: 0, mode: 'absolute' }) ], { duration: glider.options.duration, afterFinish: function() { glider.setAnimating(false); }.bind(glider) }); } } }, speedscroll: function() { var glider = this; return { prepa function(el, i) { if (i > 0) { $(el).setStyle('left: ' + glider.sectionWidth + 'px;'); } else { glider.toggleControl($$('a[href="#' + el.id + '"]')[0]); } }, animate: function(elementIdToShow, direction) { $(elementIdToShow).setStyle('left: ' + (direction === 'normal' ? glider.sectionWidth : -glider.sectionWidth) + 'px;'); $(elementIdToShow).setStyle({zIndex: 5}); $(glider.current.id).setStyle({zIndex: 1}); var currentId = glider.current.id; new Effect.Move(elementIdToShow, { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.linear, duration: glider.options.duration / 2, afterFinish: function() { moveCurrent.cancel(); $(currentId).setStyle('left: ' + (direction === 'normal' ? -glider.sectionWidth : glider.sectionWidth) + 'px;'); glider.setAnimating(false); } }); var moveCurrent = new Effect.Move(glider.current.id, { x: direction === 'normal' ? -glider.sectionWidth : glider.sectionWidth, y: 0, mode: 'absolute', transition: Effect.Transitions.linear, duration: glider.options.duration }); } } }, fade: function() { var glider = this; return { prepa function(el, i) { if (i > 0) { el.setOpacity(0); $(el).setStyle({ zIndex : '0' }); } else { glider.toggleControl($$('a[href="#' + el.id + '"]')[0]); $(el).setStyle({ zIndex : '998' }); $$('.easyslidecontrolwr')[0].setStyle({ zIndex : '999' }); } }, animate: function(elementIdToShow, direction) { $(elementIdToShow).setStyle({ zIndex : '998' }); $(glider.current.id).setStyle({ zIndex : '0' }); new Effect.Opacity(glider.current.id, { duration: glider.options.duration, from: 1.0, to: 0.0, afterFinish: function() { new Effect.Opacity(elementIdToShow, { duration: glider.options.duration, from: 0.0, to: 1.0, afterFinish: function() { glider.setAnimating(false); }.bind(glider) }); }.bind(glider) }); } } }, blend: function() { var glider = this; return { prepa function(el, i) { if (i > 0) { el.setOpacity(0); $(el).setStyle({ zIndex : '0' }); } else { glider.toggleControl($$('a[href="#' + el.id + '"]')[0]); $(el).setStyle({ zIndex : '998' }); $$('.easyslidecontrolwr')[0].setStyle({ zIndex : '999' }); } }, animate: function(elementIdToShow, direction) { $(elementIdToShow).setStyle({ zIndex : '998' }); $(glider.current.id).setStyle({ zIndex : '0' }); new Effect.Parallel([ new Effect.Opacity(glider.current.id, { sync: true, duration: glider.options.duration, from: 1.0, to: 0.0 }), new Effect.Opacity(elementIdToShow, { sync: true, duration: glider.options.duration, from: 0.0, to: 1.0 }) ], { duration: glider.options.duration, afterFinish: function() { glider.setAnimating(false); }.bind(glider) }); } } }, mosaic: function() { var glider = this; var delayedAppear = function(eSquare) { var opacity = Math.random(); new Effect.Parallel([ new Effect.Appear ( eSquare, {from: 0, to: opacity, duration: this.options.duration} ), new Effect.Appear ( eSquare, {from: opacity, to: 0, duration: this.options.duration/1.25} ) ], {sync: false}); }; return { prepa function(el, i) { if (i > 0) { el.setStyle({ zIndex : 0 }); el.hide(); } else { el.setStyle({ zIndex : 999 }); glider.toggleControl($$('a[href="#' + el.id + '"]')[0]); } if (i == (glider.sections.length - 1)) { glider.eSquares = []; var elDimension = el.getDimensions(); var elWidth = elDimension.width; var elHeight = elDimension.height; var sqWidth = elWidth / glider.options.eCols; var sqHeight = elHeight / glider.options.eRows; $R(0, glider.options.eCols-1).each(function(col) { glider.eSquares[col] = []; $R(0, glider.options.eRows-1).each(function(row) { var sqLeft = col * sqWidth; var sqTop = row * sqHeight; glider.eSquares[col][row] = new Element('div').setStyle({ opacity : 0, backgroundColor : glider.options.eColor, position : 'absolute', zIndex : 5, left : sqLeft + 'px', top : sqTop + 'px', width : sqWidth + 'px', height : sqHeight + 'px' }); el.up('div').insert(glider.eSquares[col][row]); }.bind(glider)) }.bind(glider)); } }, animate: function(elementIdToShow, direction) { $(elementIdToShow).setStyle({ zIndex : 999 }); $(glider.current.id).setStyle({ zIndex : 0 }); new Effect.Parallel([ new Effect.Fade(glider.current.id, {sync: true}), new Effect.Appear(elementIdToShow, {sync: true}) ], { duration: glider.options.duration, afterFinish: function() { glider.setAnimating(false); }.bind(glider) }); $R(0, glider.options.eCols-1).each(function(col) { $R(0, glider.options.eRows-1).each(function(row) { var eSquare = glider.eSquares[col][row]; var delay = Math.random() * (glider.options.duration / 3) * 1000; setTimeout(delayedAppear.bind(glider, eSquare), delay); }.bind(this)) }.bind(this)); } } }, setAnimating: function(flag) { this.animating = flag; if (flag) { $$('.easyslidecontrolwr')[0].addClassName('disabled'); } else { $$('.easyslidecontrolwr')[0].removeClassName('disabled'); } }, addObservers: function(){ this.wrapper.observe('mouseover', this.events.mouseover); this.wrapper.observe('mouseout', this.events.mouseout); var descriptions = this.wrapper.getElementsBySelector('div.sliderdescription'); descriptions.invoke('observe', 'mouseover', this.makeActive); descriptions.invoke('observe', 'mouseout', this.makeInactive); //Nubmbers var controls = this.wrapper.getElementsBySelector('div.easyslidercontrol a.easyslidedirect'); controls.invoke('observe', 'click', this.numClick.bind(this)); //Arrows var stop = this.wrapper.getElementsBySelector('div.easyslidercontrol a.easyslidestop'); stop.invoke('observe', 'click', this.stop.bind(this)); var play = this.wrapper.getElementsBySelector('div.easyslidercontrol a.easyslideplay'); play.invoke('observe', 'click', this.start.bind(this)); var prev = this.wrapper.getElementsBySelector('div.easyslidercontrol a.easyslideprev'); prev.invoke('observe', 'click', this.previous.bind(this)); var next = this.wrapper.getElementsBySelector('div.easyslidercontrol a.easyslidenext'); next.invoke('observe', 'click', this.next.bind(this)); }, numClick: function(event){ var element = Event.findElement(event, 'a'); /*clicked link*/ var nextElementId = element.href.split('#')[1]; var direction = 'normal'; for (var i in this.slideRelations) { if (i === this.current.id) { direction = 'normal'; break; } if (i === nextElementId) { direction = 'reverse'; break; } } this.animate(nextElementId, direction); Event.stop(event); }, animate: function(elementIdToShow, direction){ if (this.animating || this.current.id == elementIdToShow) { return; } this.setAnimating(true); this.toggleControl($$('a[href="#' + elementIdToShow + '"]')[0]); this.effects[this.options.effectType].bind(this)().animate(elementIdToShow, direction); this.current = $(elementIdToShow); }, next: function(event){ var nextMove = ''; nextMove = this.slideRelations[this.current.id]; this.animate(nextMove, 'normal'); if (event) { Event.stop(event); } }, previous: function(event){ var prevMove = ''; for (var i in this.slideRelations) { if (this.slideRelations[i] == this.current.id) { prevMove = i; break; } } this.animate(prevMove, 'reverse'); if (event) { Event.stop(event); } }, makeActive: function(event){ var element = Event.findElement(event, 'div'); element.addClassName('active'); }, makeInactive: function(event){ var element = Event.findElement(event, 'div'); element.removeClassName('active'); }, toggleControl: function(el){ if (!el) return false; $$('.easyslidercontrol a').invoke('removeClassName', 'active'); el.addClassName('active'); }, stop: function(event){ this.handStopped = true; clearTimeout(this.timer); Event.stop(event); }, start: function(event){ this.handStopped = false; this.periodicallyUpdate(); if (event) { Event.stop(event); } }, pause: function(event){ if (!this.handStopped) { clearTimeout(this.timer); this.timer = null; } Event.stop(event); }, resume: function(event){ if (!this.handStopped) { this.periodicallyUpdate(); } }, periodicallyUpdate: function(){ if (this.timer != null) { clearTimeout(this.timer); this.next(); } this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options.frequency * 1000); } }); Somewhere there each time a image appears I want it to go to a certain link (for example purposes: google.com). How can I do this? I imagine there is a onClick event somewhere in there but I just cannot find it. Thanks! Similar TutorialsI'm a php developer and have come across a mind boggling issue involving Javascript. I'm uploading images to a server without issue. They are being returned to the page in thumbnails. The script works great but I can't get the links for the images that I've uploaded. If I right click and view the image I can see the link on the server. How would I go about getting that link? If I look at the source code the link isn't present. Its a dynamically generated link for the uploaded image. Being completely unfamiliar with Javascript I'm hoping someone here can help me out. Here's the code I'm working with: Code: <input type="file" name="u" size="40" style="width:500px"/><br/> </div> <style type="text/css"> .flashUpload {width : 151px;} </style> <script> document.write('<script type="text/javascript" language="JavaScript" src="mytoken"' + '><' + '/script>'); function processUrlResponse(pic,error,window) { if ( window.parent != 'undefined' ) $(window).remove(); } var errorTexts = { 'ERROR' :'There was an error uploading your picture.', 'FS' : 'The file size of the picture you attempted to add is too large. Please reduce your picture\'s file size before adding it again.', 'FP' : 'You specified a picture file that could not be found on your computer.', 'ME' : 'There was an error uploading your picture. ', 'FC' : 'The content of your picture file is corrupted.', 'FF' : 'There was a problem with the format of your picture file.', 'SD' : 'There was a problem connecting to Picture Services.' }; var popupMsg = '<CENTER class="modal">' + '<TABLE height=210 cellSpacing=0 cellPadding=0 width=240 border=1>' + '<TR vAlign=top align=left><TD>' + '<TABLE cellSpacing=0 cellPadding=6 width="100%" border=0>' + '<TR><TD align=right><div class="closeBtn close"> </div></TD></TR>' + '<TR align=middle>' + '<TD><B><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#003399 size=4><I>' + 'Loading Pictures' + '</I></FONT><P><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#003399 size=2>' + 'Please wait.' + '</B></FONT><BR><BR><img src="myupload.com/busy.gif"/></p></TD></TR></TABLE></TD></TR></TABLE></CENTER>'; var imageUpload = { disableFlashResize :true, uploadUrl : 'myupload.com', dataField : 'Photo', thumbnailSizeId : '14', defaultSizeId : '18', removeText : 'Remove', cancelText : 'Cancel', retryText : 'Retry upload', uploadingText : 'Image uploading', flash_button_width : 151, flash_button_height : 18, flash_button_text : '<span class="button">Select Images</span>', flash_button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt;font-weight:bold;} .buttonSmall { font-size: 10pt; }', flash_button_text_top_padding : 1, flash_button_text_left_padding : 11, errorTexts : errorTexts, popupMsg : popupMsg }; My head is spinning. Hello, I am trying to connect images to some anchor tags, but each anchor matches a specific image. The aim is that when someone clicks on a certain link it will display an image (which is some text information). I have some code from a previous thread which I gained a really good script from the help. I'm not sure how to connect these anchors to the specific image. I'm sure this code only needs tweaking slightly to give me what I need. Here is the code relevant to my issue: HTML: Code: <div id="faqBox"> <h1 id="faqHeader"><u>F.A.Q's</u></h1> <ul> <li><a href="#" onclick="">What is the purpose of this website?</a></li> <li><a href="#">What type of achievements would someone of had to do to be eligable?</a></li> <li><a href="#">Why was this award created?</a></li> <li><a href="#">How do we nominate somebody?</a></li> <li><a href="#">How are people presented with this award?</a></li> </ul> </div> <div id="faqInfoBox"> <img src="images/content1.png" name="allimage" id="allimage" alt="content1" border="0" /> </div> CSS: Code: #faqInfoBox {width: 40%; border: 5px ridge; height: 310px; background: #606626; float: right; margin-right: 3%;} #faqBox ul li{font-family: trebuchet ms; line-height: 30px; list-style-type: square;} JS: Code: var imgArray = new Array(4); imgArray[0] = 'images/content1.png'; imgArray[1] = 'images/content2.png'; imgArray[2] = 'images/content3.png'; imgArray[3] = 'images/content4.png'; imgArray[4] = 'images/content5.png'; var currIndex = 0; function imgChange(that) { if(currIndex < myImages.length - 1) { that.src = myImages[++currIndex]; }else { currIndex = 0; that.src = myImages[currIndex]; } } The JavaScript is what needs tweaking. I also have it uploaded to my free domain which you can find the site he http://abjava.host22.com/Site1/ if you would care to take a look. I don't want to be fed the answer but just some pointers/tips on what I could do. I was thinking of connecting the function to the anchor tags onclick event. But because I need the specific images to display when their relative link is clicked I know it could be harder to do this. I want to stack the images on top of each other and hide their display then when a link is clicked show it, when another is clicked, hide the first and show that one. (Please note,the last 4 images have not yet been created). I can figure out to do the CSS for this so just any help on the JS side will be very helpful to me. Thank you very much in advance if anyone can help. Regards, LC. Hello, I need the links to the rotating images to open in a new window. Is there an easy way to do this? Here is my code: [CODE] <script type="text/javascript"> var preload_ctrl_images=true; //And configure the image buttons' images he var previmg='left.gif'; var stopimg='stop.gif'; var playimg='play.gif'; var nextimg='right.gif'; var slides=[]; //FIRST SLIDESHOW //configure the below images and descriptions to your own. slides[0] = ["/pics/nav/home2/music-club_manatella.jpg", "", "/progs/main/manatella.pdf"]; slides[1] = ["/pics/nav/home2/teen-read-week2011.jpg", "", "/teens/teen-read-week2011.pdf"]; slides[2] = ["/pics/nav/home2/oceanway-express.jpg", "", "/lib/branches/OWY.html"]; slides[3] = ["/pics/nav/home2/jea-green.jpg", "", "/progs/jpl/home-energy-evaluation.html"]; slides[4] = ["/pics/nav/home2/childrens-summer-reading.jpg", "", "/kids/kids-summer-reading2011.pdf"]; slides[5] = ["/pics/nav/home2/teen-summer-reading.jpg", "", "/teens/teens-summer-reading2011.pdf"]; slides[6] = ["/pics/nav/home2/internet-safety.jpg", "", "/Training/Internet-Safety/internet-safety.html"]; slides.no_descriptions=1; //use for no descriptions displayed //use for no descriptions displayed //above slide show uses only the defaults </script> <script src="http://jpl.coj.net/common/javascripts/swissarmy.js" type="text/javascript"> </script> [CODE] [URL]http://jpl.coj.net Thank you so much for your help, Elbee Hi all I've been looking now for over a week on how create this http://instances.110mb.com/ effect when you hover over the ships on that page. I would be eternally grateful for any ideas how to replicate this effect. Thanks Rob Hi. I'm Matthew, the creator of the Easing Slider Wordpress plugin. Currently I'm working on the next update of the slider which is to allow the user to assign a link to each image. This is working fine with the slide animations but is creating problems with the fade animation (note I'm using jQuery). Here are the two issues: 1) Using .animate({opacity:0}) & .animate({opacity:1}) the slider is only linking to the link assigned to the last image in the slider. The links are supposed to link: 1. google.com, 2. hotmail.com & 3. fadebook.com. However the slider is only linking to the last link (facebook.com). 2) Using .fadeIn & .fadeOut everything appears to work correctly and the links correspond to the images however when using the pagination before the image has finished fading can cause the images to disappear or appear not fully faded. You can see the overall code he http://pastebin.com/9JwaM9tg (check lines 72, 215 & 216) Example (using .animate): http://www.matthewruddy.com/demo/ I've spent ages trying to figure this out but I really am struggling and cannot find a solution. Many people use the fade effect and I don't particularly want to get rid of it but I will have to if I can't find a solution. I would appreciate if anyone could help me out. Thanks in advance. Matthew. hey guys this is my first post, looking at the sheer wwealth of knowledge on here i thought you guys would be the best people to ask. I have created a photography website myself and coded it all in dreamweaver cs4. Now i have created it using html, as i didnt want to limit it to flash users and loading times etc etc. So today i found myself a nice simple slideshow tool that uses html and javascript. i created it using a site online (which i will not post as i dont think we are allowed to post to online sites). The slideshow loads images up in the background, and it plays them in a random order. Now i am able to define individual image links to either a url of the an image, or point it to individual images, listing them one by one in my coding, which as a photographer having differet galleries is goign to be a royal pain when i want to have new images showing up. So my idea is to replace the code that retrieves in dividual images from url's, to replace it with a piece of code that will display an image from a list of about 7 or 8 folders on my server all containing images.... i.e. displays an image from the folder .../images/models/pic01.jpg then it brings up an iamge from a different folder .../images/portrait/pic08.jpg. Is there a way to do this and how can i go about it? this is the code i currently have: Code: <!-- configurable script --> <script type="text/javascript"> theimage = new Array(); // The dimensions of ALL the images should be the same or some of them may look stretched or reduced in Netscape 4. // Format: theimage[...]=[image URL, link URL, name/description] theimage[0]=["/images/models/photo01.jpg", "", ""]; theimage[1]=["/images/models/photo02.jpg", "", ""]; theimage[2]=["/images/models/photo03.jpg", "", ""]; theimage[3]=["/images/models/photo04.jpg", "", ""]; theimage[4]=["/images/models/photo05.jpg", "", ""]; ///// Plugin variables playspeed=3000;// The playspeed determines the delay for the "Play" button in ms dotrans=1; // if value = 1 then there are transitions played in IE transtype='revealtrans';// 'blendTrans' or 'revealtrans' transattributes='0';// duration=seconds,transition=#<24 //##### //key that holds where in the array currently are i=0; //########################################### //if random function SetRandom() { tempimage = new Array(); for(p=0; p<theimage.length; p++){ for(p1=0; p1>-1; p1) { tempNum = Math.floor(Math.random()*theimage.length) if(!tempimage[tempNum]){ tempimage[tempNum]=theimage[p]; break; } } } for(p=0;p<theimage.length;p++)theimage[p]=tempimage[p]; } //if random order SetRandom() //########################################### window.onload=function(){ //preload images into browser preloadSlide(); //set transitions GetTrans(); //set the first slide SetSlide(0); //autoplay PlaySlide(); } //########################################### function SetSlide(num) { //too big i=num%theimage.length; //too small if(i<0)i=theimage.length-1; //switch the image if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Apply()') document.images.imgslide.src=theimage[i][0]; if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()') } //########################################### function PlaySlide() { if (!window.playing) { PlayingSlide(i+1); if(document.slideshow.play){ document.slideshow.play.value=" Stop "; } } else { playing=clearTimeout(playing); if(document.slideshow.play){ document.slideshow.play.value=" Play "; } } // if you have to change the image for the "playing" slide if(document.images.imgPlay){ setTimeout('document.images.imgPlay.src="'+imgStop+'"',1); imgStop=document.images.imgPlay.src } } //########################################### function PlayingSlide(num) { playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed); } //########################################### //desc: picks the transition to apply to the images function GetTrans() { //si=document.slideshow.trans.selectedIndex; if((document.slideshow.trans && document.slideshow.trans.selectedIndex == 0) || (!document.slideshow.trans && dotrans==0)){ dotrans=0; } else if ((document.slideshow.trans && document.slideshow.trans.selectedIndex == 1) || (!document.slideshow.trans && transtype == 'blendTrans')){ dotrans=1; transtype='blendTrans'; document.imgslide.style.filter = "blendTrans(duration=1,transition=1)"; }else{ dotrans=1; transtype='revealtrans'; if(document.slideshow.trans) transattributes=document.slideshow.trans[document.slideshow.trans.selectedIndex].value; document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")"; } } //########################################### function preloadSlide() { for(k=0;k<theimage.length;k++) { theimage[k][0]=new Image().src=theimage[k][0]; } } </script> then this is the little bit of html Code: <!-- slide show HTML --> <form name="slideshow"> <table border="1" cellpadding="2" cellspacing="0"> <tr> <td align="center"> <a href="#" onMouseOver="this.href=theimage[i][1];return false"> <script type="text/javascript"> document.write('<img name="imgslide" id="imgslide" src="'+theimage[0][0]+'" border="0">') </script> </a> </td> </tr> </table> </form> <!-- end of slide show HTML --> hope someone can shed a little light on this for me thank you Chris here is an example of the problem (and how to produce it): 1) go to http://eataustineat.com/testfolder/index.php 2) type in an 'a' into the text field 3) click "view results" 4) select the first result (ie: Dog Almighty) Notice the javascript slide doesn't happen. In fact, nothing appears to happen. It is suppose to slide the content to the left much like it did when you hit "view results". Why? I hope this clears the problem up some. I have a frameset with 2 frames. I have simple flash video playing in the left frame (jwplayer) with an html menu underneath the will fast forward to a specific time in the video with javascript. Works great. In the right frame I have a pdf document that I want to setup so when the user user clicks the simple link under the video it also goes to a specific page within the pdf document in the right frame. Hope this makes sense and thanks in advance for the help. here is one of the html links from the video menu. Code: <a href="#" class="style1" onclick="player.sendEvent('SEEK',0); return false;">Item 1</a> Can any one please tell me a way to get all the links in a web page using javascript?
Hi Everyone, I have a strange problem that I can't resolve. Have a look at www.snaptease.co.uk/random.html and you will see a random image every time you refresh. Now look at www.snaptease.co.uk/random1.html and you won't see the image. The only difference is in the js/random.js and js/random1.js each file references. js/random.js uses the same html link to index.html js/random1.js links to individual html files that exist and valid. The working code looks like this: [CODE] images[0] = "<a href = 'index.html'><img src='images/games/aa01q.jpg' alt='album art' title='Do you recognise this album?'></a>";[CODE] The non working code looks like this: [CODE] images[0] = "<a href = 'answers/aa01.html'><img src='images/games/aa01q.jpg' alt='album art' title='Do you recognise this Album?'></a>";[CODE] Even if I enter the full url it makes no difference. Please tell me what I am doing wrong and how to fix it. I've been banging my head over this for a while now so I would appreciate any help. Thanks in advance Martin Okay, this is a long-winding problem, but I'll do my best to explain it. I am creating a website for my ICT coursework which I have been making using frames as a basis for the layout. On one of the pages, I have included a calendar, which itself is in a frame. Essentially, what I have is a frame within a frame. Certain made up events in the calendar were linked to another page on my site- when you clicked on that link, it closed the calendar frame, and opened the link within the original frame, using this code: Code: "<a href='link.htm' rel="nofollow" target='frame' onclick='window.close();'><center><img src='IMAGE' border='0'></a>" I had to include this within the Javascript file, and because of the original coding, I can't use " "s in the coding, or it breaks the statement, so I can only use ' ' within the two. I got this code from Script Calendar. Initially, this code to open the links worked, closing one frame and opening the link in another. However, now when I click it, it opens in a new window. I really don't know what exactly to edit, as my experience is minimal with Javascript. I know it's very overcomplicated, but I would really appreciate any help at all! Thank you! Hello, I'm having a strange problem. I have a visio diagram displayed on a Sharepoint 2010 page. It's a chart, and each item within it links to a relevant item in a Sharepoint list, displayed in a modal window using a bit of JavaScript. The problem is it works in everything but Internet Explorer! Could anyone help? IE doesn't display any errors. Code: function openDialog(id){ var addString = '&ContentTypeID=0x010093E0E47DAEC14BF5AA399AF47613F91F005BDB7D7682432C4F98DF9B7670EF440C'; var modalUrl = id + addString; options = SP.UI.$create_DialogOptions(); options.url = "../mysharepoint/display.aspx?" + modalUrl; options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback); SP.UI.ModalDialog.showModalDialog(options); } function CloseCallback(result, target) { location.reload(true); } I've created a slideshow on our site using the java template at http://www.javascriptkit.com/script/.../jsslide.shtml Are there simple modifications I can make to this code in order to cause clicking on the image links to go straight to them, rather than creating a new window/tab? Thanks for the help. Below is a javascript function from my website that loops through nodes in an XML file retrieving certain information about those who joined in the current month/year. The part in red creates a link which when clicked runs a function called show() with the relevant i variable value e.g. show(2) for the second node if that is relevant. Anyway the red part works in Chrome but not Internet Explorer (surprise surprise). I did some research which says that .setattribute is not allowed in IE. How can I change the red code to create links for the relevant records which works in IE? Thank you for your help Code: function displaymember() { var d = new Date(); var curr_month = d.getMonth(); curr_month++; if (curr_month < 10) curr_month = "0" + curr_month; var curr_year = d.getFullYear(); for (i = 0; i < x.length; i++) { membershipstatus = (x[i].getElementsByTagName("membership_status")[0].childNodes[0].nodeValue); name = (x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue); body = (x[i].getElementsByTagName("body_type")[0].childNodes[0].nodeValue); ethnicity = (x[i].getElementsByTagName("ethnicity")[0].childNodes[0].nodeValue); sex = (x[i].getElementsByTagName("sex")[0].childNodes[0].nodeValue); seeking = (x[i].getElementsByTagName("seeking")[0].childNodes[0].nodeValue); date = (x[i].getElementsByTagName("date_joined")[0]); month = (date.getElementsByTagName("month")[0].childNodes[0].nodeValue); year = (date.getElementsByTagName("year")[0].childNodes[0].nodeValue); newa = document.createElement("a"); aIdName = "my" + i + "a"; ahref = "#"; aclick = "show(" + i + ")"; newa.setAttribute("id", aIdName); newa.setAttribute("href", ahref); newa.setAttribute("onclick", aclick); newa.innerHTML = name + " | " + body + " " + ethnicity + " " + sex + " with " + membershipstatus + " membership seeks " + seeking + "<br/>"; if (curr_month == month && curr_year == year) { document.getElementById("member").appendChild(newa); } } } Okay. So here's what I'm trying to do. I have my landing page to my site and near the bottom I have 4 little 48x48 class divs (for social network link images if you were wondering ). Each Class div has a background style all to it's own. (so in this case 4 different divs with 4 different class names) . What I want to do with the javascript is to have a function(s) that when called on (depending on which div.class was/is clicked on) will open up a lightbox/new page containing the new page (pertaining to the appropriate social network, depending on which class has been clicked on). I don't want to put an <a></a> tag around the div.classes themselves seperately because the landing page itself has 8 different styles, plus the div.classes I would have to hunt down within the site itself. haha Basically in short I want the classes to have seperate links that when clicked upon it calls the function, opens the lightbox (or opens the new tab/page) and loads the appropriate page. Think yall can help me out here? Ahoy, Lemme try to explain this as best as I can. Bullet points might help: When someone clicks on an image here (http://gta.kwivia.co.uk/gta-iv/), the rest of the images collapse and become invisible Below the image, some links appear Also, there will be a "show other images" button which will then show the rest of the images http://gta.kwivia.co.uk/gta-iv/ I will appreciate all solutions to this problem. If you need to know anything, simply ask me. I hate javascript.... OK, here's my latest challenge with Javascript. I recently went into twp php files and made a few very minor changes to some outdated $date functions. Now, I have three small icons for 'copy', 'paste','delete' using the javascript 'onclick' function that have stopped working. In fact, when I replace the two recently revised files with the originals, these icons no longer work there either. Any help would be appreciated. I'm simply at a total loss for ideas here. From the primary php file is the relevant lines of source code....As far as I can tell, the second paragraph in each area is returning a 'null' value; i.e. o1a.options.selectedIndex is null. Code: function aCopy(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); avail_1a = o1a.options.selectedIndex; avail_1b = o1b.options.selectedIndex; avail_2a = o2a.options.selectedIndex; avail_2b = o2b.options.selectedIndex; avail_3a = o3a.options.selectedIndex; avail_3b = o3b.options.selectedIndex; } function aPaste(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); o1a.options.selectedIndex = avail_1a; o1b.options.selectedIndex = avail_1b; o2a.options.selectedIndex = avail_2a; o2b.options.selectedIndex = avail_2b; o3a.options.selectedIndex = avail_3a; o3b.options.selectedIndex = avail_3b; } function aDelete(dt){ o1a = document.getElementById("avail_1a_" + dt); o1b = document.getElementById("avail_1b_" + dt); o2a = document.getElementById("avail_2a_" + dt); o2b = document.getElementById("avail_2b_" + dt); o3a = document.getElementById("avail_3a_" + dt); o3b = document.getElementById("avail_3b_" + dt); o1a.options.selectedIndex = 0; o1b.options.selectedIndex = 0; o2a.options.selectedIndex = 0; o2b.options.selectedIndex = 0; o3a.options.selectedIndex = 0; o3b.options.selectedIndex = 0; From the supporting php file are the following lines of code.... Code: $s .= "<td nowrap=nowrap class=calendar style='border-left:1px dashed #000;'>"; $s .= "<a href='javascript:void(0);' onclick=\"aCopy('$year-$month-$d');\"><img src='../admin/_calendar/Copy.gif' alt='Copy Availability' width='16' height='16' border='0' /></a>"; $s .= " <a href='javascript:void(0);' onclick=\"aPaste('$year-$month-$d');\"><img src='../admin/_calendar/Paste.gif' alt='Paste Availability' width='16' height='16' border='0' /></a>"; $s .= " <a href='javascript:void(0);' onclick=\"aDelete('$year-$month-$d');\"><img src='../admin/_calendar/Delete.gif' alt='Delete/No Availability' width='16' height='16' border='0' /></a>"; $s .= "</td>"; None of these lines of code were changed or altered when I was updating the code. Any thoughts or suggestions would be deeply appreciated? Talltom Instead of using window.open, which I understand opens a new window, is there a code that will make the link open in the parent window?
Hi guys, I need some help. Im trying to make a navagation menu with images that need to be changed when someone hovers over the child category. So lets say I have a menu that looks like this: Code: <img src="notactiveimagemenu1.jpg" alt=""> <ul id="menu1"> <li>link</li> <li>link</li> <li>link</li> </ul> <img src="notactiveimagemenu2.jpg" alt=""> <ul id="menu2"> <li>link</li> <li>link</li> <li>link</li> </ul> Now what im trying to do is if someone hovers over the li items from menu1 to change the image src of menu1.jpg to active. I was hoping to do this with some javascript. Code: // i was thinking about something like this: // first put menu items in a array // then use document.getElementById(id).onmouseover = function() // and make some sort of check to see which src should be changed. Now I really have no clue how to do it. So if anyone knows a cool solution please let me know. I know I could add onmouseover events to each li item and changing the src of the category. But Im trying to find a better solution. And I think I should be able to use document.getElementById(id).onmouseover = function() for that. Anyway thanks for any tips. Please note I know I could use jquery to do all of this very easy but I consider this practice because I don't know that much javascript. |