JavaScript - Alternating Links
Hello,
I am setting up a demo system for the company I work for. It uses logmein so the user can test out our software. I have 2 machines running with the. ASIC software and 2 running the advanced software. What I need are 2 alternating links so the user clicks on "test advanced" it takes them to test machine 1 in a new tab and when the the nest user. Clicks on the link it opens machine 2. Basically just alternating between the 2 links. Is that possible! Thanks, William Similar Tutorialsi'm having problems getting the functions i created to do the same thing i got it to do for 1 id, for 5 other ids. i basically want 6 images to change when someone does mouseover,out,down, and up (the button technique). this is what i have so far for 1 of them: Code: function mouseOver() { document.getElementById("about").src ="images/splash_up_04.png"; } function mouseOut() { document.getElementById("about").src ="images/splash_04.png"; } function mouseDown() { document.getElementById("about").src ="images/splash_down_04.png"; } function mouseUp() { document.getElementById("about").src ="images/splash_up_04.png"; } and the html for it is: Code: <div id="slice_4"><a href="#"><img alt="" src="images/transparent_splash_04.png" id="about" onmouseover="mouseOver()" onmouseout="mouseOut()" onmousedown="mouseDown()" onmouseup="mouseUp()" /></a></div> i have 5 more links i need to have to do the same thing that this one does.. only problem is, i'm striking out figuring out how exactly to accomplish it any help would be appreciated, or links that would put me on the right path. thanks again <3 I am trying to build a function that when a link is checked, the js will check it for its top level domain and if it is other than a .gov, will produce an alert. What I have come up with is the following: Code: $domains = array(".aero",".biz",".cat",".com",".coop",".edu",".info",".int",".jobs",".mil",".mobi",".museum", ".name",".net",".org",".travel",".ac",".ad",".ae",".af",".ag",".ai",".al",".am",".an",".ao",".aq",".ar",".as",".at",".au",".aw", ".az",".ba",".bb",".bd",".be",".bf",".bg",".bh",".bi",".bj",".bm",".bn",".bo",".br",".bs",".bt",".bv",".bw",".by",".bz",".ca", ".cc",".cd",".cf",".cg",".ch",".ci",".ck",".cl",".cm",".cn",".co",".cr",".cs",".cu",".cv",".cx",".cy",".cz",".de",".dj",".dk",".dm", ".do",".dz",".ec",".ee",".eg",".eh",".er",".es",".et",".eu",".fi",".fj",".fk",".fm",".fo",".fr",".ga",".gb",".gd",".ge",".gf",".gg",".gh", ".gi",".gl",".gm",".gn",".gp",".gq",".gr",".gs",".gt",".gu",".gw",".gy",".hk",".hm",".hn",".hr",".ht",".hu",".id",".ie",".il",".im", ".in",".io",".iq",".ir",".is",".it",".je",".jm",".jo",".jp",".ke",".kg",".kh",".ki",".km",".kn",".kp",".kr",".kw",".ky",".kz",".la",".lb", ".lc",".li",".lk",".lr",".ls",".lt",".lu",".lv",".ly",".ma",".mc",".md",".mg",".mh",".mk",".ml",".mm",".mn",".mo",".mp",".mq", ".mr",".ms",".mt",".mu",".mv",".mw",".mx",".my",".mz",".na",".nc",".ne",".nf",".ng",".ni",".nl",".no",".np",".nr",".nu", ".nz",".om",".pa",".pe",".pf",".pg",".ph",".pk",".pl",".pm",".pn",".pr",".ps",".pt",".pw",".py",".qa",".re",".ro",".ru",".rw", ".sa",".sb",".sc",".sd",".se",".sg",".sh",".si",".sj",".sk",".sl",".sm",".sn",".so",".sr",".st",".su",".sv",".sy",".sz",".tc",".td",".tf", ".tg",".th",".tj",".tk",".tm",".tn",".to",".tp",".tr",".tt",".tv",".tw",".tz",".ua",".ug",".uk",".um",".us",".uy",".uz", ".va",".vc", ".ve",".vg",".vi",".vn",".vu",".wf",".ws",".ye",".yt",".yu",".za",".zm",".zr",".zw"); if ($domains == true) { alert(); } else { //do nothing } I am not truly fluent with js and need help with the function. My idea is to get away from having to apply an onclick/onkeypress to each link and apply this code externally or in line to each page. Any suggestions? Thanks Alan hello I,m using js to parse an XML file. the values from each node are written into an HTML table. this all works fine. however when I try to read a web address from the XML and use it as the href in my <a> tag the page jumps straight to the URL specified. how can I prevent this happening? 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> I'm trying to create something like: http://www.deliciouslysortedibiza.com/ But I want the links to move like it does in there. Does anyone know the easiest way I could achieve this? Since I'm fairly new to Javascript and all. Thanks ! Hello everyone, I have a situation where in my navigational menu (which is an unordered list) when someone has Internet Explorer that it takes them to a different link than if they have a different browser. It is a long story why I need it to do this but suffice it to say, it has to be that way. Is there any script would allow for such a thing? And by the way it has nothing to do with different browser CSS capabilities, I know how to do that already. I am relying on you Zen coders out there whose wisdom far exceeds mine. (Which is definitely not hard to do..) So my goal was to insert a mini ICO image (of an R) and have it be a link to an external news page for each individual player on a fantasy team. The code below gets the proper link to each player and inserts the image and corresponding link one at a time though a couple different functions. I have inserted the IMG successfully (see attached), but I am having issues with the link. There are times when the images load accurately with the correct link and others when some of the 'href' elements say undefined. And it isn't consistent either, as to imply that it is a specific coding error. It is completely random and sometimes they are even all correct. Could this have something to do with the asynchronicity of the GM_xmlhttprequests and the loop? If so, is there some way to get around that? This is the bottom of the code which gets fed an array teamURL with all the proper URLs. All of the variables and arrays have the correct information, as they have been checked and double checked. It is almost as if I need a way to slow down the loop to let it do its thing... if that makes any sense. Code: var count = 0; var item = 0; for (var k=0; k< myPlayersArray.length; k++) { GM_xmlhttpRequest({ method:"GET", url:teamURL[k], headers:{"User-Agent":"Mozilla/5.0","Accept":"text/xml"}, onload:function(response){findInfo(response);} }) ; } var allElements = document.evaluate("//*[contains(@href, 'http://sports.yahoo.com/nfl/players/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); var baseRotoworldURL = 'http://www.rotoworld.com'; function findInfo( response ) { var doc = document.createElement( "div" ) ; doc.innerHTML = response.responseText ; //Get appropriate td data on the rankings page var teamPageList = document.evaluate("//a[contains(@href, 'player')]",doc,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); for (var m=0; m<teamPageList.snapshotLength; m++) { if ((teamPageList.snapshotItem(m).innerHTML.toString()) == (myPlayersArray[count].toString())) { var playerHTML = teamPageList.snapshotItem(m).parentNode.innerHTML; var match = playerHTML.match(/\/nfl\/\d{1,10}\/[a-z]+\-[a-z]+/); var playerURL = baseRotoworldURL +"/recent" + match break; //loop until you get a hit } } addGameLogIcon(allElements, playerURL); count++; } function addGameLogIcon(allElements, playerURL) { var thisElement; var rotoworldLink; var rotoworldLinkGraphic = "data:image/gif;base64,"+"AAABAAEADw8AAAEAGAA0AwAAFgAAACgAAAAPAAAAHgAAAAEAGAAAAAAAAAAAAEgAAABIAAAAAAAAAAAAAADR09TR09TR0tPR0tPQ0tPQ0tPQ0tPQ0dTQ0tPQ0tPQ0tPQ0dPQ0tPR09TR09S9AADR09TR09TP0dOvssuan8acocfFx9HQ0tPGyNGdocean8edocfDxdDR09TR09S9AADR09TR09TGydFHRsEsKNsrJ9SGicLP0dNsb74rJ9csKNsrJ8iTlcPR09TR09S9AADR09TR09TEx9BFRcYvKu0sKOOChcK3ucwuKsgvKu0uKedUVMDIydHR09TR09S9AADR09TR09TEx9BERMQuKOcsJ9+ChcFnaLstJ+IuKOc0McuqrMnQ0tTR09TR09S9AADR09TR09TEx9BERMItKOEsJ9lfYbYuKsQtKOEsJ9hxc7/P0NPQ0tPR09TR09S9AADR09TR09TEx9BERMAsJ9srJ9gqJsgrJ9ksJ9sqJsdub7vJytHQ0tPR09TR09S9AADR09TR09TEx9BEQ70sJ9QsJ9UsJtQsJ9QsJtUsJtQrJspzdb3Q0dPR09TR09S9AADR09TR09TEx9BEQ7stJc4sJco8OrZJSLkxLbotJc0tJs49Ori/wM7R09TR09S9AADR09TR09TEx9BDQ7ksJ8gsJsN6fL3Bw855e7wrJcIsJ8c5Nrm7vs3R09TR09S9AADR09TR09TEx9BEQ7YtJ8IsJ780MLE+O7QuKrYsJ8EtJ8I/PLTBws/R09TR09S9AADR09TR09TEx9BERLUtKMEtKMEtJ8EtJ8EtJ8AsJ8EtKLh7fL3P0NTR09TR09S9AADR09TR09THytFMTrQpJrUpJrUpJrUpJrUvLrVGRLSKisDLzNLQ0tTR09TR09S9AADR09TR09TR09TDxdC7vc67vc67vc67vc6+wc/HytHR09TR09TR09TR09TR09S9AADR09TR09TR09TR09TR09TR09TR09TR09TR09TR09TR09TR09TR09TR09TR09S9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; thisElement = allElements.snapshotItem(item); rotoworldLink = document.createElement('a'); rotoworldLink.setAttribute("href", playerURL); rotoworldLink.setAttribute("target","_blank"); rotoworldLink.innerHTML = "<img border='0' src='" + rotoworldLinkGraphic +"'>" ; thisElement.parentNode.appendChild(rotoworldLink, thisElement.nextSibling); item=item+3; } 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=iso-8859-1" /> <title>Test Project</title> <script type="text/javascript"> var clicks=0; function linkClick(){ document.getElementById('clicked').value = ++clicks; } </script> </head> <body> <p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p> <p align="center"> </p> <p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p> <p align="center"> </p> <p align="center"><a href="http://www.google.ie" target="_blank" onclick="linkClick()">Google</a></p> <p align="center"> </p> <td colspan="3" valign="top">You have clicked my links <input id="clicked" size="1" onfocus="this.blur();" value="0" > times</td> <Script Language="JavaScript"> if ("clicks">3); { window.open('http://ie.yahoo.com','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); } </Script> </body> </html> I am a complete novice, I've spend most of today trying to research and learn Javascript. I would like my page to keep a count of how many times the links have been opened (this is happening) I would like a new pop up window to occur when the count gets to a specif value (this isnt happening) OR maybe to have a new hyperlink to appear that the user can then click on? Thanks in advance. Hi, first post here! I have inserted a 'fisheye' widget to dreamweaver. It works great. I created a link from the home button. When i test it and over the button with my mouth its shows the link but does not open the window. Would anyone have an idea or lead on how I can solve this issue? As well can i post the link of the page? Thanks for ur help and time. Im trying to run javascript on a page, that has a regular frame, and get all the links from the frame. However im not very good at javascript which makes this much harder This is the script im trying to use: Code: javascript: for(var i=0; i<window.frames.length; i++){for (i=0; i < document.links.length; i++) { alert(document.links[i].href); }}; 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'm a beginner. My links are not working in this js script. The menu renders properly, but nothing happens when I click the link. Thanks, Ed [code] <HTMl> <head> <title>JavaScript Example</title> <script language="JavaScript"> // Create array to hold four URLs; var dest = new Array(4); dest[0] = window.location.href; dest[1] = "http://www.journey.maryanngoble.com/"; dest[2] = "http://www.facebook.com/bluegrasscreative/"; dest[3] = "http://www.campbellsville.edu"; function go(d) { // Change location of current window one selected from menu // d.menu.options.selectedIndex returns a number that corresponds // to the choice they selected in the pop up menu on the form // If a user selected the first choice, selectedIndex = 0 and the // URL will be set to dest[0] or http://www.bluegrasscreative.com/ window.location.href = dest[d.destination.options.selectedIndex]; // Open new window with selected location // var x = window.open(dest[d.destination.options.selectedIndex],"New Window"); // To set the URL for another frame in this frameset // top.framename.location.href = dest[d.menu.options.selectedIndex]); } </script> </head> <body bgcolor="white"> <form name="x"> <label for="destination"><h3>Where do you want to go?</h3></label> <select id="destination" onchange="go(x)"> <option>Quick Links</option> <option value="1">MaryAnn's blog</option> <option value="2">BGC Facebook</option> <option value="3">Campbellsville University</option> </select> </form> </body> </html> [code] Hi all I believe this to be a JS quesiton, but perhaps there is something here of CSS too? I have an "ecard" which is: - a <div id="outer_ecard"> wrapping an <iframe>... - is hidden by default (via a JS function that fires onload of the parent doc), .. - that gets its display and visibility turned on when the user clicks a link in the parent doc, ... - and then gets its display and visibility turned off again via a call to that same JS function in the parent doc that hid it in the first place by default. here is just the relevant snip of the hiding JS function - Code: elementToSet.style.display = "none"; elementToSet.style.visibility = "hidden"; everything works fine, *BUT* this issue: after the <div> disappears (the 2nd time, when the above snip is triggered in the iframe's parent via an onload event in the iframe doc)... then hyperlinks (in the parent file) that are geographically positioned underneath the <div id="outer_ecard"> do not work (i.e. they still think the ecard div is sitting on top of them (z-index:1). Can anyone advise me here? I need the links underneath the ecard to behave as though that div was never there. Thanks! -Govinda I have one button - can I attach two links to it. button <img src="images/aboutusbtn.gif" alt="ABOUT US" /> link 1 - javascript toggle button <a href="javascript://" name="toggle1" id="toggle1"></a> link 2 - anchor button <a href="#c1"></a> Cheers pjking hi below is my script, what i add in a link<a href=xxx></a> for disable this script for that link regards Quote: <SCRIPT LANGUAGE="Javascript"> function PopShow3() { CookieTest=navigator.cookieEnabled; if(CookieTest) { ClickUndercookie = GetCookie('clickunder'); if (ClickUndercookie == null) { var ExpDate = new Date (); ExpDate.setTime(ExpDate.getTime() + (0 * 0 * 0 * 0)); SetCookie('clickunder','1',ExpDate, "/"); window.open("http://www.google.com"); window.focus(); } } } 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 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" : ""); } document.onmouseup=PopShow3; </SCRIPT> hi, i am totally new to JS and was wondering if anyone could just suggest me a JS code, "THAT WOULD SELECT MULTIPLE LINKS ON MOUSE CLICK" <div id="container"> <ul id="seatplan"> <li class="seat_01 A"><a href="#row_01" title="01A">01A</a></li> <li class="seat_02 A"><a href="#row_02" title="02B">02A</a></li> <li class="seat_03 A"><a href="#row_03" title="03C">03A</a></li> </ul></div> Presently, i can select ONE. these codes are assigned to images, if selected they change color. But i just want help on MULTIPLE SELECTION. thanks Hi, I'm building an html web page (no flash) and was wondering if it was possible to fade (or slide up from the horizontal rule) my navigation links into the page, one after the other, for the home page only, and ideally only for the first session visit. Aside from looking cool, I think it will draw the attention of the visitor and let them know where their main links are. I've experimented with animated .gif's, but not only was the implementation buggy, it didn't give me the flexibility to quickly edit the links. I'm thinking some sort of JavaScript (or css?) can accomplish this, but I don't know the first thing about writing JavaScript and I couldn't find any script on the web. Does anyone know if such a script does exist, or if there's a better way I should go about doing this? Thanks! Here's the structure for my main index: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="templates/styles.css"> <title>Test</title> </head> <body class="main"> <center> <table border="0" cellspacing="0" cellpadding="0" width="800" class="header"> <tr> <td align="left" valign="bottom" width="455" height="45"><a href="index.html" class="nav"><img src="images/logo.png" alt="Logo"></a></td> <td align="right" valign="bottom" width="146" height="45"> <a href="link1/index.html" class="nav">Link1</a> </td> <td align="right" valign="bottom" width="103" height="45"> <a href="link2/index.html" class="nav">Link2</a> </td> <td align="right" valign="bottom" width="96" height="45"> <a href="link3/index.html" class="nav">Link3</a> </td> </tr> <tr> <td align="center" valign="top" width="800" height="10" colspan="4"><hr noshade></td> </tr> </table> <table border="0" cellspacing="0" cellpadding="0" width="800"> <tr> <td width="800" height="10"></td> </tr> <tr> <td align="center" valign="top" width="800" height="440"> CONTENT WILL GO HERE </td> </tr> </table> <table border="0" cellspacing="0" cellpadding="0" width="800"> <tr> <td align="center" valign="bottom" height="45" class="footer"> <hr noshade> </td> </tr> </table> </center> </body> </html> I found the effect I would like to achieve here, but the code doesn't allow me to make turn the text into links, and I would like to leave the links where they are in the html and maybe the JavaScript could call each link by id? http://www.codingforums.com/showthre...072#post923072 Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> #container { width:600px; margin:auto; } #container p{ height:100%; } #p4 { font-family:'times new roman',serif; font-size:18px; color:#006; text-align:justify; } </style> <script type="text/javascript"> var lines=new Array(); lines[0]='text1'; lines[1]='text2'; lines[2]='text3'; lines[3]='text4'; lines[4]= 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula.'+ 'Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus '+ 'nisl ac enim. Maecenas vestibulum dolor ut velit. Maecenas condimentum pulvinar purus. '+ 'Pellentesque ac ipsum. Curabitur sodales, elit vel molestie hendrerit, elit odio rhoncus tellus, '+ 'nec gravida enim urna id velit. Donec nec tellus. Vestibulum nulla. Curabitur enim arcu,'+ 'ornare id, placerat eget, nonummy vitae, mauris. Nulla rutrum semper odio. Duis vulputate '+ 'ornare mauris. Praesent eget nibh sed ante ultricies scelerisque. Duis eget felis ut arcu porta '+ 'bibendum. Mauris rutrum. Vivamus consectetuer purus sit amet mi. Suspendisse eu augue.'; var c=0; var value=0; var speed=20; function addLines() { if(c>=lines.length) { return; } par=document.createElement('p'); par.setAttribute('id','p'+c); par.appendChild(document.createTextNode(lines[c])); document.getElementById('container').appendChild(par); setOpacity(); } function setOpacity() { obj=document.getElementById('p'+c); if(value>100) { value=0; c++; return addLines(); } if(obj.filters) { obj.style.filter='alpha(opacity='+value+')'; } else { obj.style.opacity=value/100; } value++; setTimeout('setOpacity()',speed); } window.onload=function() { addLines(); } </script> </head> <body> <div id="container"></div> </body> </html> I need whenever surfer click on a link , it open under windows i have underclick script , but it open under windows , when click whereever on the page i want it for speacial links what i must put in the <a href="http://www.google.com>open under click</a> Hiya! Trying to figure out how to use javascript to extract all links on a page that have a certain class: e.g. - extract only links with a class of 'tools', ignore all other links: Code: <a href="http://www.google.com" class="tools">Search</a> <a href="http://www.tripod.com" class="grapes">Searched</a> <a href="http://www.dogpile.com">Searches</a> Any help would be appreciated, I'm guessing I probably have to use something like getelementbyclass("tools")? |