JavaScript - Help Modifying A Redirect Script
Hi, I want to take this redirect script and modify it so that it rotates a banner image instead of sending the user to another page. The script works so that if the window is out of focus for 10 seconds, it redirects. The images are defined in an external style sheet so I guess I'll have to move that into the document. Also, I want it to be able to work more than once with multiple images, like if the user opens a new tab, comes back, goes to a different tab, the image should change twice. Here's the script:
Code: <script type="text/javascript"> var xScroll, yScroll, timerPoll, timerRedirect, timerClock; function initRedirect(){ if (typeof document.body.scrollTop != "undefined"){ //IE,NS7,Moz xScroll = document.body.scrollLeft; yScroll = document.body.scrollTop; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling timerRedirect = setInterval("location.href='http://www.google.com",10000); //set timed redirect } else if (typeof window.pageYOffset != "undefined"){ //other browsers that support pageYOffset/pageXOffset instead xScroll = window.pageXOffset; yScroll = window.pageYOffset; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling timerRedirect = setInterval("location.href='http://www.google.com'",10000); //set timed redirect } //else do nothing } function pollActivity(){ if ((typeof document.body.scrollTop != "undefined" && (xScroll!=document.body.scrollLeft || yScroll!=document.body.scrollTop)) //IE/NS7/Moz || (typeof window.pageYOffset != "undefined" && (xScroll!=window.pageXOffset || yScroll!=window.pageYOffset))) { //other browsers initRedirect(); //reset polling scroll position } } document.onmousemove=initRedirect; document.onclick=initRedirect; document.onkeydown=initRedirect; window.onload=initRedirect; window.onresize=initRedirect; </script> The image is defined in Code: <div id="home" style="background: url(images/banner.png) no-repeat;"></div> I'm thinking I should replace banner.png with a variable or array name that has the image names defined somewhere and using a loop to choose the next image in the array. I took a C++ class but I don't know any JS, sorry for not doing homework. Thanks for reading this Similar TutorialsHello, I have a script that makes a link a different color on click, i would like to add a hover color to the links that are NOT active. Script below. Thanks in advance! Code: function activate(el) { var links=document.getElementsByTagName("a"); for(i=0;i<links.length;i++) { if(links[i].className=="toggle") { links[i].style.color="#999"; } } el.style.color="#DF8700"; } Hi all, I found a small fading script online which suits my needs though I need some help changing it around a bit as it seems to only work once in a page (i.e. a second occurance of the code doesn't work though the first one continues). Also, I'm not quite sure how to put it into a .js external page and then call the specific function as many times as I want in the body and have it all work. Please advise on this issue (i.e. Putting the code in an external file and then calling the fadeIn() function as many times as I want in the body). Thanks. BTW, the concept is a fixed imaged with the js fading another image over the top of that first image in and out over and over again. All the images and application of the js will be the same for all occurrences on the page (don't know if that's relevant to the solution I'm asking for but throwing it in there just in case). Here is the code: Code: <html> <body style="background:#000;"> <div style="float:left;"> <img style="float:left;" id="me" src="fade_arrow2.png"/> <img style="float:left;margin-left:-44px;" src="fade_arrow1.png"/> <script type="text/javascript"> var element = document.getElementById('me') ; var duration = 4000; /* 1000 millisecond fade = 1 sec */ var steps = 20; /* number of opacity intervals */ var delay = 5000; /* 5 sec delay before fading out */ /* set the opacity of the element (between 0.0 and 1.0) */ function setOpacity(level) { element.style.opacity = level; element.style.MozOpacity = level; element.style.KhtmlOpacity = level; element.style.filter = "alpha(opacity=" + (level * 100) + ");"; } function fadeIn(){ for (i = 0; i <= 1; i += (1 / steps)) { setTimeout("setOpacity(" + i + ")", i * duration); } setTimeout("fadeOut()", delay); } function fadeOut() { for (i = 0; i <= 1; i += (1 / steps)) { setTimeout("setOpacity(" + (1 - i) + ")", i * duration); } setTimeout("fadeIn()", duration); } /* start the effect */ fadeIn(); </script> </div> </body> </html> I am trying to modify a popup script to popup a lightbox on page load instead of a new window. The script identifies if the user is a new visitor and displays the popup only to new visitors. Typically, the lightbox is triggered by an a:link. I would like to trigger it using this script so that the lightbox pops up automatically for new visitors only. Here is the popup script: Code: <SCRIPT LANGUAGE="JavaScript"> <!-- 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 "here"; i=document.cookie.indexOf(" ",i)+1; if (i==0) break; } return null; } var visit=GetCookie("COOKIE1"); if (visit==null){ var expire=new Date(); window.name = "thiswin"; newwin=open("http://www.pccmedia.net/P25_60sec.php", "dispwin", "width=350,height=350,scrollbars=yes,menubar=no"); expire=new Date(expire.getTime()+7776000000); document.cookie="COOKIE1=here; expires="+expire; } // --> </SCRIPT> I want to replace the newwin=open... command with something that will trigger the lightbox. The section of the lightbox script that receives the trigger and variables is.... Code: Mediabox.scanPage = function() { // $$('#mb_').each(function(hide) { hide.set('display', 'none'); }); var links = $$("a").filter(function(el) { return el.rel && el.rel.test(/^lightbox/i); }); $$(links).mediabox({/* Put custom options here */}, null, function(el) { var rel0 = this.rel.replace(/[[]|]/gi," "); var relsize = rel0.split(" "); return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1])); }); }; window.addEvent("domready", Mediabox.scanPage); An example of the typical HTML tag that triggers the lightbox and feeds the variables is Code: <a href="http://www.pccmedia.net/other/P25_60sec.mp4" rel="lightbox[set 720 405]" title="Project 25" onClick="stop1()"/> The rel=lightbox... is the trigger for the lightbox. The stop1() function refers to a separate script that plays background music on the website. This also needs to be included in the new visitor popup script, but is a separate issue..... I'm not familiar enough with JS to be able to figure this out. Any help would be GREATLY appreciated. Here is the style and js for my menu that I got from Dynamic Drive. I have it working as it is suppose to on my site. But I need my menus to have submenus and even have a couple of sub-submenus. Can someone help me with this. Code: YOffset=150; // no quotes!! XOffset=0; staticYOffset=30; // no quotes!! slideSpeed=20 // no quotes!! waitTime=100; // no quotes!! this sets the time the menu stays out for after the mouse goes off it. menuBGColor="black"; menuIsStatic="yes"; //this sets whether menu should stay static on the screen menuWidth=180; // Must be a multiple of 10! no quotes!! menuCols=2; hdrFontFamily="verdana"; hdrFontSize="2"; hdrFontColor="white"; hdrBGColor="#170088"; hdrAlign="left"; hdrVAlign="center"; hdrHeight="15"; linkFontFamily="Verdana"; linkFontSize="2"; linkBGColor="white"; linkOverBGColor="#FFFF99"; linkTarget="_top"; linkAlign="Left"; barBGColor="#FF0000"; barFontFamily="Verdana"; barFontSize="3"; barFontColor="white"; barVAlign="center"; barWidth=45; // no quotes!! barText="Menu Navigation"; // <IMG> tag supported. Put exact html for an image to show. /////////////////////////// // ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header ssmItems[0]=["Menu"] //create header ssmItems[1]=["About Our Diocese", "http://www.ptdiocese.org/about-us/about-us.shtml, ""] ssmItems[2]=["Parishes", "http://www.ptdiocese.org/parishes/parish.shtml",""] ssmItems[3]=["Schools", "http://www.ptdiocese.org/schools/schools.shtml", ""] ssmItems[4]=["Ministries", "http://www.ptdiocese.org/christian-formation/christian-formation.shtml", "_new"] ssmItems[5]=["Clergy and Religous", "http://www.ptdiocese.org/clergy-religious/clergy-religious.shtml", ""] ssmItems[6]=["Protecting God's Children", "http://www.ptdiocese.org/protecting-children/protecting-children.shtml", ""] ssmItems[7]=["For Those In Need", "http://www.ptdiocese.org/in-need/in-need.shtml", ""] ssmItems[8]=["Tribunal", "http://www.ptdiocese.org/tribunal/tribunal.shtml", ""] ssmItems[9]=["Contact Us"] //ssmItems[7]=["Tribunal", "http://www.ptdiocese.org", "", 1, "no"] //create two column row //ssmItems[8]=["Contact Us", "http://www.ptdiocese.org", "",1] ssmItems[10]=["External Links", "", ""] //create header ssmItems[11]=["Test", "http://www.javascriptkit.com", ""] ssmItems[12]=["Test", "http://www.freewarejava.com", ""] ssmItems[13]=["Test", "http://www.codingforums.com", ""] buildMenu(); //--> NS6 = (document.getElementById&&!document.all) IE = (document.all) NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4") tempBar='';barBuilt=0;ssmItems=new Array(); function truebody(){ return (document.compatMode!="BackCompat")? document.documentElement : document.body } moving=setTimeout('null',1) function moveOut() { if ((NS6||NS)&&parseInt(ssm.left)<0 || IE && ssm.pixelLeft<0) { clearTimeout(moving);moving = setTimeout('moveOut()', slideSpeed);slideMenu(10)} else {clearTimeout(moving);moving=setTimeout('null',1)}}; function moveBack() {clearTimeout(moving);moving = setTimeout('moveBack1()', waitTime)} function moveBack1() { if ((NS6||NS) && parseInt(ssm.left)>(-menuWidth) || IE && ssm.pixelLeft>(-menuWidth)) { clearTimeout(moving);moving = setTimeout('moveBack1()', slideSpeed);slideMenu(-10)} else {clearTimeout(moving);moving=setTimeout('null',1)}} function slideMenu(num){ if (IE) {ssm.pixelLeft += num;} if (NS6) {ssm.left = parseInt(ssm.left)+num+"px";} if (NS) {ssm.left = parseInt(ssm.left)+num; bssm.clip.right+=num;bssm2.clip.right+=num;}} function makeStatic() { if (NS||NS6) {winY = window.pageYOffset;} if (IE) {winY = truebody().scrollTop;} if (NS6||IE||NS) { if (winY!=lastY&&winY>YOffset-staticYOffset) { smooth = .2 * (winY - lastY - YOffset + staticYOffset);} else if (YOffset-staticYOffset+lastY>YOffset-staticYOffset) { smooth = .2 * (winY - lastY - (YOffset-(YOffset-winY)));} else {smooth=0} if(smooth > 0) smooth = Math.ceil(smooth); else smooth = Math.floor(smooth); if (IE) bssm.pixelTop+=smooth; if (NS6) bssm.top=parseInt(bssm.top)+smooth+"px" if (NS) bssm.top=parseInt(bssm.top)+smooth lastY = lastY+smooth; setTimeout('makeStatic()', 1)}} function buildBar() { if(barText.indexOf('<IMG')>-1) {tempBar=barText} else{for (b=0;b<barText.length;b++) {tempBar+=barText.charAt(b)+"<BR>"}} document.write('<td align="center" rowspan="100" width="'+barWidth+'" bgcolor="'+barBGColor+'" valign="'+barVAlign+'"><p align="center"><font face="'+barFontFamily+'" Size="'+barFontSize+'" COLOR="'+barFontColor+'"><B>'+tempBar+'</B></font></p></TD>')} function initSlide() { if (NS6){ssm=document.getElementById("thessm").style;bssm=document.getElementById("basessm").style; bssm.clip="rect(0 "+document.getElementById("thessm").offsetWidth+" "+document.getElementById("thessm").offsetHeight+" 0)";ssm.visibility="visible";} else if (IE) {ssm=document.all("thessm").style;bssm=document.all("basessm").style bssm.visibility = "visible";} else if (NS) {bssm=document.layers["basessm1"]; bssm2=bssm.document.layers["basessm2"];ssm=bssm2.document.layers["thessm"]; bssm2.clip.left=0;ssm.visibility = "show";} if (menuIsStatic=="yes") makeStatic();} function buildMenu() { if (IE||NS6) {document.write('<DIV ID="basessm" style="visibility:hidden;Position : Absolute ;Left : '+XOffset+'px ;Top : '+YOffset+'px ;Z-Index : 20;width:'+(menuWidth+barWidth+10)+'px"><DIV ID="thessm" style="Position : Absolute ;Left : '+(-menuWidth)+'px ;Top : 0 ;Z-Index : 20;" onmouseover="moveOut()" onmouseout="moveBack()">')} if (NS) {document.write('<LAYER name="basessm1" top="'+YOffset+'" LEFT='+XOffset+' visibility="show"><ILAYER name="basessm2"><LAYER visibility="hide" name="thessm" bgcolor="'+menuBGColor+'" left="'+(-menuWidth)+'" onmouseover="moveOut()" onmouseout="moveBack()">')} if (NS6){document.write('<table border="0" cellpadding="0" cellspacing="0" width="'+(menuWidth+barWidth+2)+'px" bgcolor="'+menuBGColor+'"><TR><TD>')} document.write('<table border="0" cellpadding="0" cellspacing="1" width="'+(menuWidth+barWidth+2)+'px" bgcolor="'+menuBGColor+'">'); for(i=0;i<ssmItems.length;i++) { if(!ssmItems[i][3]){ssmItems[i][3]=menuCols;ssmItems[i][5]=menuWidth-1} else if(ssmItems[i][3]!=menuCols)ssmItems[i][5]=Math.round(menuWidth*(ssmItems[i][3]/menuCols)-1); if(ssmItems[i-1]&&ssmItems[i-1][4]!="no"){document.write('<TR>')} if(!ssmItems[i][1]){ document.write('<td bgcolor="'+hdrBGColor+'" HEIGHT="'+hdrHeight+'px" ALIGN="'+hdrAlign+'" VALIGN="'+hdrVAlign+'" WIDTH="'+ssmItems[i][5]+'" COLSPAN="'+ssmItems[i][3]+'"> <font face="'+hdrFontFamily+'" Size="'+hdrFontSize+'" COLOR="'+hdrFontColor+'"><b>'+ssmItems[i][0]+'</b></font></td>')} else {if(!ssmItems[i][2])ssmItems[i][2]=linkTarget; document.write('<TD BGCOLOR="'+linkBGColor+'" onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'" WIDTH="'+ssmItems[i][5]+'px" COLSPAN="'+ssmItems[i][3]+'"><ILAYER><LAYER onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'" WIDTH="100%" ALIGN="'+linkAlign+'"><DIV ALIGN="'+linkAlign+'"><FONT face="'+linkFontFamily+'" Size="'+linkFontSize+'"> <A HREF="'+ssmItems[i][1]+'" target="'+ssmItems[i][2]+'" CLASS="ssmItems">'+ssmItems[i][0]+'</DIV></LAYER></ILAYER></TD>')} if(ssmItems[i][4]!="no"&&barBuilt==0){buildBar();barBuilt=1} if(ssmItems[i][4]!="no"){document.write('</TR>')}} document.write('</table>') if (NS6){document.write('</TD></TR></TABLE>')} if (IE||NS6) {document.write('</DIV></DIV>')} if (NS) {document.write('</LAYER></ILAYER></LAYER>')} theleft=-menuWidth;lastY=0;setTimeout('initSlide();', 1)} Hi, I am using this image rotation tool on my website but I would like to alter it slightly http://www.zurb.com/playground/orbit...y-image-slider See the small navigation dots under the images to select individual pages there are 4 of them (more if you add more images) - on 1 horizontal line. I would like to alter the code if possible so that the dots are in pairs going down the page (I wont bore you with the reason why) ie: o o o o o o o o etc The code the handles the dots is this: Code: // ================== // ! BULLET NAV // ================== //Bullet Nav Setup if(options.bullets) { var bulletHTML = '<ul class="orbit-bullets"></ul>'; orbitWrapper.append(bulletHTML); var bullets = orbitWrapper.children('ul.orbit-bullets'); for(i=0; i<numberSlides; i++) { var liMarkup = $('<li>'+(i+1)+'</li>'); if(options.bulletThumbs) { var thumbName = slides.eq(i).data('thumb'); if(thumbName) { var liMarkup = $('<li class="has-thumb">'+i+'</li>') liMarkup.css({"background" : "url("+options.bulletThumbLocation+thumbName+") no-repeat"}); } } orbitWrapper.children('ul.orbit-bullets').append(liMarkup); liMarkup.data('index',i); liMarkup.click(function() { stopClock(); shift($(this).data('index')); }); } setActiveBullet(); } //Bullet Nav Execution function setActiveBullet() { if(!options.bullets) { return false; } else { bullets.children('li').removeClass('active').eq(activeSlide).addClass('active'); } } The CSS for this is: Code: /* BULLET NAV ================================================== */ .orbit-bullets { position: absolute; z-index: 1000; list-style: none; bottom: 150px; left: 0%; margin-left: 0px; padding: 0; } .orbit-bullets li { float: left; margin-left: 5px; cursor: pointer; color: #999; text-indent: -9999px; background: url(bullets.png) no-repeat 4px 0; width: 13px; height: 12px; overflow: hidden; } .orbit-bullets li.active { color: #222; background-position: -8px 0; } .orbit-bullets li.has-thumb { background: none; width: 100px; height: 75px; } .orbit-bullets li.active.has-thumb { background-position: 0 0; border-top: 2px solid #000; } The image file for the small dots is this: I'm afraid I'm not a Java person at all and know little about it so I would be very grateful if you could help me out with it... if it's possible. Thanks. PP. Hi everyone, I have a countdown script I'd like to modify so that the countdown ends at a specific hour, and not on a particular day at midnight. I'm new to coding (Ruby), so still trying to get the hang of Javascript: Code: var current="Expired" var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") function countdown(yr,m,d){ theyear=yr;themonth=m;theday=d var today=new Date() var todayy=today.getYear() if (todayy < 1000) todayy+=1900 var todaym=today.getMonth() var todayd=today.getDate() var todayh=today.getHours() var todaymin=today.getMinutes() var todaysec=today.getSeconds() var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec futurestring=montharray[m-1]+" "+d+", "+yr dd=Date.parse(futurestring)-Date.parse(todaystring) dday=Math.floor(dd/(60*60*1000*24)*1) dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1) dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1) dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1) if(dday==0&&dhour==0&&dmin==0&&dsec==1){ document.getElementById('counter').style.display='none'; document.getElementById('expired').style.display='block'; return } else{ document.getElementById('countdown_day').innerHTML=dday; document.getElementById('countdown_hour').innerHTML=dhour; document.getElementById('countdown_min').innerHTML=dmin; document.getElementById('countdown_sec').innerHTML=dsec; setTimeout("countdown(theyear,themonth,theday)",1000) } } //MODIFY THIS LINE: enter the count down date using the format year/month/day //e.g. countdown(2009, 03, 23); countdown(2011, 12, 24); I've tried to play with it by changing the following in green: Code: function countdown(yr,m,d, h ){ theyear=yr;themonth=m;theday=d; thehour=h . . . setTimeout("countdown(theyear,themonth,theday, thehour )",1000) . . countdown(2011, 12, 24, 10 ) But I don't seem to be getting anywhere. Any tips or pointers to push me in the right direction is much appreciated. Thanks! Hi all, I have been using a border-fading script to give the impression of onmouseover fading underline, and I wish to tweak it a bit to give a slightly different effect I have two scripts that do virtually the same thing, although the second has a display bug in FF both have their advantages and I don't have my heart set on using either one, although Vic's scripts are being used all over the page i'm creating so his has first dibs here they are, and I will describe what I need to do below: first script: Code: startColor = "FFFFFF"; // MouseOut link color endColor = "000000"; // MouseOver link color stepIn = 20; // delay when fading in stepOut = 30; // delay when fading out var fading=new Array(); fading['now']=startColor; function initLinkFade() { var links = document.getElementById('pageHolder').getElementsByTagName('A'); for(var i=0;i<links.length;i++){ links[i].onmouseover = domouseover; links[i].onmouseout = domouseout; } } if(document.getElementsByTagName){ window.onload = initLinkFade; document.write("<style type='text/css'>#pageHolder a{text-decoration:none}</style>"); } function domouseover() { var rel="nofollow" target=arguments[0]?arguments[0].target:event.srcElement; if(target.nodeName!='A')return; for(var i=0;i<fading.length;i++) clearTimeout(fading[i]); if(fading['el']!=target && fading['el']){ fading['el'].style.borderBottom = "1px solid #"+startColor; linkFade(startColor,endColor,target,stepIn); } else linkFade(fading['now'],endColor,target,stepIn); } function domouseout() { var rel="nofollow" target=arguments[0]?arguments[0].target:event.srcElement; if(target.nodeName!='A')return; for(var i=0;i<fading.length;i++) clearTimeout(fading[i]); if(fading['el']!=target && fading['el']){ fading['el'].style.borderBottom = "1px solid #"+startColor; linkFade(endColor,startColor,target,stepOut); } else linkFade(fading['now'],startColor,target,stepOut); } function hex(i) { var s=Math.floor(i).toString(16); return s.length==2?s:"0"+s; } function linkFade(s,e,element,step){ fading['el']=element; var sr=parseInt(s.substr(0,2),16); var sg=parseInt(s.substr(2,2),16); var sb=parseInt(s.substr(4,2),16); var er=parseInt(e.substr(0,2),16); var eg=parseInt(e.substr(2,2),16); var eb=parseInt(e.substr(4,2),16); for(var i = 0; i <= step; i++) { var r=hex((sr*(step-i)+er*i)/step); var g=hex((sg*(step-i)+eg*i)/step); var b=hex((sb*(step-i)+eb*i)/step); fading[i]=setTimeout("fading['now']='"+r+g+b+"';fading['el'].style.borderBottom = '1px solid #'+fading['now']",i*step); } } What I like about this one is that you can specify both the fade in and fade out speeds, allowing you a bunch of flexibility in how it looks also, I like how it allows you to set it to 'apply to all links in a given div... however that can have certain downfalls you can seethis script in action he www.enviromark.ca/head/YPP.htm the second script Code: <!-- // by Vic Phillips (04-September-2006) http://www.vicsjavascripts.org.uk function zxcMseOver(zxcobj,zxcd){ var zxcp=zxcobj; if (!zxcp.oop){ return; } clearTimeout(zxcp.oop.to); zxcp.oop.d=zxcd||0; zxcp.oop.cng(); } function zxcInit(zxccls,zxccol1,zxccol2,zxcstps){ var zxclks=document.getElementsByTagName('BODY')[0].getElementsByTagName('A'); for (var zxc0=0;zxc0<zxclks.length;zxc0++){ if (zxclks[zxc0].className==zxccls){ zxcStyle(zxclks[zxc0],{borderBottom:'solid '+zxccol1+' 0px;'}); zxclks[zxc0].oop=new zxcOOP(zxclks[zxc0],zxccol1,zxccol2,zxcstps); } } } var zxcCnt=0; function zxcOOP(zxcd,zxccol1,zxccol2,zxcstps){ this.obj=zxcd; this.ary=zxcSTxtColors([zxccol1,zxccol2],zxcstps||10); this.cnt=0; this.d=1 this.to=null; this.ref='zxcoop'+zxcCnt; window[this.ref]=this; zxcCnt++; } zxcOOP.prototype.cng=function(){ if ((this.d>0&&this.cnt<this.ary.length-1)||(this.d<0&&this.cnt>0)){ this.obj.style.borderBottom='solid #'+this.ary[this.cnt+=this.d]+' 1px'; this.setTimeOut("cng();",100); } else if (this.d<0) { this.obj.style.borderBottom='0px'; } } zxcOOP.prototype.setTimeOut=function(zxcf,zxcd){ this.obj.to=setTimeout("window."+this.ref+"."+zxcf,zxcd); } function zxcStyle(zxcele,zxcstyle){ if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); } for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; } return zxcele; } function zxcSTxtColors(zxcc,zxcnu){ var zxcary=[]; zxcc1=zxcc[0].replace('#',''); zxcc2=zxcc[1].replace('#',''); var zxcr=zxcHexToInt(zxcc1.substring(0,2)); var zxcg=zxcHexToInt(zxcc1.substring(2,4)); var zxcb=zxcHexToInt(zxcc1.substring(4,6)); var zxcr2=zxcHexToInt(zxcc2.substring(0,2)); var zxcg2=zxcHexToInt(zxcc2.substring(2,4)); var zxcb2=zxcHexToInt(zxcc2.substring(4,6)); var zxcrstep=Math.round((zxcr2-zxcr)/zxcnu); var zxcgstep=Math.round((zxcg2-zxcg)/zxcnu); var zxcbstep=Math.round((zxcb2-zxcb)/zxcnu); for (zxc0=0;zxc0<zxcnu;zxc0++){ zxcary[zxc0]=zxcIntToHex(zxcr)+zxcIntToHex(zxcg)+zxcIntToHex(zxcb); zxcr+=zxcrstep; zxcg+=zxcgstep; zxcb+=zxcbstep; } zxcary[zxcnu-1]=zxcc[1].substring(1); return zxcary; } function zxcIntToHex(zxcn){ zxcn=(zxcn>255)?255:(zxcn<0)?0:zxcn; var zxcresult=zxcn.toString(16); if (zxcresult.length==1){ zxcresult="0"+zxcresult; } return zxcresult; } function zxcHexToInt(zxchex){ return parseInt(zxchex,16); } //--> activated by: <body onload="zxcInit('mainLinks','#FFFFFF','#000000',15);"> ... <a class="mainLinks" href="#advantagesRisks" onmouseover="zxcMseOver(this,1);" onmouseout="zxcMseOver(this,-1);"><img src="images/EN_advantages_risks.gif" name="imageLinkNoTouchy"></a> I like this script because it allows you to set the fade on a per-link basis, not on a per-div basis... more control alrighty, here are the minor modifications I am hoping to get help with The fade-out effects stop when a second link is onmouseover'd. I would like to be able to set both the fade-in and fade-out delays (like in the first script), but have the fade-out continue for "Link A" even if "Link B" is onmouse'd over. Basically getting the smooth-fade effect seen he www.enviromark.ca/head/ --> the gray icons. When a link is clicked, I would like the top border of the link to fade in and stay solid until another link is clicked. When another link is clicked, I would like it's top border to fade in (like the first link) a have the first link's top border fade out. Again you can see the effect I'm going for at the link above by clicking on a few of the vertical links and seeing it's effect on the horizontal images I know this might be a lot to ask, so I suppose I could live with the script I have... but I figured there was no harm in asking Hello all, Firstly apologies for my javascript ignorance - I'm not a programmer, just someone thrust into programming since there's no-one else at my company who can do it. I found a nice js script online for a drop-down menu where the drop downs both expand to their full size and fade-in (very quickly) from transparent. The script in action can be seen on the script writer's site he http://sandbox.leigeber.com/dropdown-menu/index.html and the script is: Code: var menu=function(){ var t=15,z=50,s=6,a; function dd(n){this.n=n; this.h=[]; this.c=[]} dd.prototype.init=function(p,c){ a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0; for(i;i<l;i++){ var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i]; h.onmouseover=new Function(this.n+'.st('+i+',true)'); h.onmouseout=new Function(this.n+'.st('+i+')'); } } dd.prototype.st=function(x,f){ var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0]; clearInterval(c.t); c.style.overflow='hidden'; if(f){ p.className+=' '+a; if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0} if(c.mh==c.offsetHeight){c.style.overflow='visible'} else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)} }else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)} } function sl(c,f){ var h=c.offsetHeight; if((h<=0&&f!=1)||(h>=c.mh&&f==1)){ if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'} clearInterval(c.t); return } var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh; c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')'; c.style.height=h+(d*f)+'px' } return{dd:dd} }(); with Code: var menu=new menu.dd("menu"); menu.init("menu","menuhover"); used on my html page to call the script. I'm using the script exactly as written and exactly as it is on the dude's demo page for it. However, some of my sub-menu items are wider than their parent items and in IE7 this means they are bound to the width of the parent until the animations have finished, and then pop-out to their full width (NB not an issue in FF3). I'm actually not too fussed about either the fade in or expand out effects (they'd be nice, but not at the expense of the IE7 bug) so I simply wanted to know what I should do to the script to turn off the effects, or make them instant - ie reduce the length of the effect to as short as possible. I understand I can get rid of the bug by specifying a width for the ul element in my css, but I'd rather not do that if I can help it. I'd appreciate anyone's insight on this. Thanks Tom Hi there, Im very new to all this and have only been working with scripts for a few days, so simple pointers would be greatly appriciated. My problem; I play an online strategy game where i can use scripts to help my game play. There is a quick bar at the top of the game screen which i can add scripts to. When editing the bar there are 3 options. 1. Name, 2. Image URL, 3. Target URL. The script i have written is entered into the Target URL. It works fine but i have to be on a certain page in the game to run the script because of how it gets the required info. At the minute i have two scripts doing what i would like one to do. The first script (that i wrote) and a second which just redirects me to the right page (which i have to click first). Can i get both tasks on to one script. What i would like the script to do is, upon clicking redirect me to the appropriate page the script needs to be run from, and then run the javascript function. My Script; ( which isnt finished but works fine for now) Code: JavaScript: var n = prompt("1.Plunder / Looting 2. OD 3.Archer 4.Axe ", "1");n = parseInt(n); if(n == 1) {var stringOne = (document.getElementsByTagName("img")[12].title);var stringTwo = (document.getElementsByTagName("img")[10].title);var stringThree = (document.getElementsByTagName("img")[25].title);var stringFour = (document.getElementsByTagName("img")[24].title);var stringFive = stringOne + " \n" + stringTwo + " \nToday " + stringThree + " \nToday " + stringFour + "";alert (stringFive );}; if(n == 2) {var stringSix = (document.getElementsByTagName("img")[15].title);var stringSeven = (document.getElementsByTagName("img")[22].title);var stringEight = (document.getElementsByTagName("img")[23].title);var stringNine = stringSix + " \nToday as attacker " + stringSeven + " \nToday as defender " + stringEight + "";alert (stringNine );}; To sum up. Basicly i want to be able to click the link to this script and have it redirect me to the right page and then run. So where would i put the page address and how do i make the script rum when the page is loaded. Here is what I am looking to do. I want a user to click a link and auto log into a site and then start a certain citrix app. I am not a Java programmer so my skills in this error are limited. I did put a script together that is below but it is very sloppy. It passes the credentials and logs in to Citrix and auto starts the app but it has to have two pages open to do this. Is there not a way to have Java log into a site then pass it back to the original page so it can finish the script to auto start the app. Thanks for the help. Code: <html> <head> <title>Post Page</title> <SCRIPT LANGUAGE="JavaScript"> <!-- function loginCitrix(){ go1(); go2(); } function go1() { CitrixForm.submit(); } function go2() { setTimeout('document.location="http://ctx.server1.com/Citrix/XenApp/site/launcher.aspx?CTX_Application=Citrix.MPS.App.CitrixProd.Notepad&LaunchId=1301587978804"',3000) } //--> </SCRIPT> <body onLoad="loginCitrix();"> <form method="POST" action="http://ctx.server1.com/Citrix/XenApp/auth/login.aspx" name="CitrixForm" rel="nofollow" target="_blank"><br> <input type='hidden' name='user' value='username'><br> <input type='hidden' name='password' value='password'><br> <input type='hidden' name='domain' value='corpdc'><br> <input type='hidden' name='LoginType' value='Explicit'><br> </form> </body> </html> Hi, I am trying to implement a script which redirects visitors to one of 24 html pages based on the hour it is when they visit. I have tried a number of other script I could find and nothing even close to working has been achieved. The pages are named: 0.html, 1.html, 2.html.....up to....22.html & 23.html I already have a simple script in use for the day of the week and am sure there must be something similar I can do for the hour of day. Any help that can be offered will be greatly appreciated as this is driving me mad. Can anyone help me out with a script that can redirect based on IP address? I want all of my computers on my LAN, 192.168.1.1-255 to be redirected to a specific page. IE When I type in test.homeip.com it goes to my web server and reads the index.html file. If the IP is in the 192.168.1.0 range it will redirect to 192.168.1.10:80 and if its any other IP it will send it to 192.168.1.11:80 Thanks! Perhaps this wouldn't even be Javascript, but here's my question. Is there a script that would direct Opera users past the front page of a web site (that uses flash) to the home page? For instance, a site I'm building as a favor to a church has a flash intro page that is fine with every browser but Opera. (Opera doesn't respond to Autoplay but places a large "Play" button where the flash is located.) On this particular page, the flash movie ends with an "Enter" instruction and is a hyperlink to the "home" page, so if an Opera user clicks that button, they're still not going to see the flash but are going to arrive at the "home" page. Is there a way to not even present them with the flash page, but to send them straight to the home page? I'd appreciate any assistance. Friends, I am looking for a PHP or Java Script to integrete in a PHP CMS, that enables to Redirect to Another URL when the script sense that the visitor is going away from the page. (Hit back button, hit refresh button and so on....) It should be unblockable by browsers. May anyone suggest me one or share the codes. I will use it for personal purpose and not for comercial purpose at all. Thanks Hi, I am pretty much a noob when it comes to javascript. I am looking for a script that redirects random.html to 1 of 86 predefined pages, randomly. If someone could help me out, that would be great. Thanks for your help Hi, Please i am not getting clear understanding of a javascript code to redirect user to a different web page based on the day of the week. Please i have search for many script and not getting clear understanding from their code.I have also try several code myself but nothing good has come from it. Please can someone help me and write a descriptive code for me to understand better.I really plead you and your to help me...but i belief the Lord God will bless you for your time helping me. looking forward to here from you. Thank you. Clement Osei Hello everyone. I have a a html page that is used as a login page. I know it is not secure but this is just for learning purposes, I'm not using it for anything important. My problem is that when I put in the correct login all that happens is the page just clears the text boxes as if you were starting over. I am trying to get it to go to register.html which is located in the same directory as the login page. Help with what I'm doing wrong would be greatly appreciated. Here is the code: Code: <html> <head> <title>Login Page</title> </head> <body> <script type = "text/javascript"> var count = 2; function validate() { var un = document.myform.username.value; var pw = document.myform.pword.value; var valid = false; var unArray = ["Philip", "George", "Sarah", "Michael"]; // as many as you like - no comma after final entry var pwArray = ["Password1", "Password2", "Password3", "Password4"]; // the corresponding passwords; for (var i=0; i <unArray.length; i++) { if ((un == unArray[i]) && (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("Login was successful"); window.location = "register.html"; return false; } var t = " tries"; if (count == 1) {t = " try"} if (count >= 1) { alert ("Invalid username and/or password. You have " + count + t + " left."); document.myform.username.value = ""; document.myform.pword.value = ""; setTimeout("document.myform.username.focus()", 25); setTimeout("document.myform.username.select()", 25); count --; } else { alert ("Still incorrect! You have no more tries left!"); document.myform.username.value = "No more tries allowed!"; document.myform.pword.value = ""; document.myform.username.disabled = true; document.myform.pword.disabled = true; return false; } } </script> <form> <table border ="5"> <tr> <th colspan="2">Login</th> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pword" /></td> </tr> <tr> <th colspan="2"><input type="Submit" value="Login" name="Submit" onClick="validate()" /><input type="Reset" value="Reset" /></th> </tr> </table> <p> <a href="register.html">New users click here to register</a> </p> </form></body></html> Hi All, I have this javaascript which validates fields on a form, and if one of the fields are empty or 0 it will turn that field red, but it does it individually and i want it to turn all fields that are in error in red at the same time, can someone help me with the below code on how i can accomplish this Code: var inputsToCheck = Array('MainDisplayContentChange_txtTitleContent', 'MainDisplayContentChange_txtDescription', 'MainDisplayContentChange_txtjusitification','MainDisplayContentChange_txtDateRequired'); var obj;0 function formCheck() { for(var i=0;i<inputsToCheck.length;i++) { obj = document.getElementById(inputsToCheck[i]); if (obj.value == "") { obj.style.backgroundColor = "red"; return false } else { return true } } } Im new to javascript so this could be a simple change for someone with more knowledge then my self. the webpage is built with ASP.Net Thanks in Advance I am very new to js. I have a jquery plugin that is a live countdown timer and I would like to modify it. Can someone tell me how to modify the code below so that the date is 20 minutes from right now (currently it is set as 26 January 2013). Code: <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26); $('#defaultCountdown').countdown({until: austDay}); $('#year').text(austDay.getFullYear()); }); </script> Hi guys, For some reason the following code is not working. Anybody see any issues? By default the style of #pricea in my stylesheet is visibility="hidden"; Code: <script type="text/javascript"> function arrow(boxName){ document.getElementById(boxName).style.visibility = "visible"; } </script> <?php if($_REQUEST['sort']=="price" && $_REQUEST['order']=="ASC"){ ?> <script type="text/javascript"> arrow('pricea'); </script> <?php }?> |