JavaScript - Is It Possible To Initiate An Automated Click At A Specific Time?
First off, I apologize if I'm in the wrong area. I was referred to the site here by a neighbor of mine that has used these forums in the past.
Before I move forward with finding someone to help me with some kind of a browser extension, I need to know if it is even possible to do. I have zero experience with anything code related, but wanted to do a little leg work here. The basic goal is to be able to input a specific time of day, and have the code execute a click on a button or link. The more specific the timing can be, the better. I've done a little research over the past couple evenings, and I see that there are ways to use time intervals. I would if possible like to use exact hour, minutes, seconds, and even milliseconds. Alternatively, if anyone has come across something that already does what I'm looking for. I would be much appreciative if you could point me in that direction. Thank you all for your time. Similar TutorialsHey: I have several "submit" buttons on a form. I want users to be able to hit the "enter" key to submit the form. The page used to "post" the information checks for specifically what form button was pushed to submit the form before executing the appropriate code. I am automatically submitting the page when the enter key is hit, but it is defaulting to the first option of executed code in the post page. Example - I have an "update" button and a "delete" button on the form. On the post page, I first check to see if the delete button was hit. When I press enter on the form, it simply answers yes to the first question (did they click the delete button), and the code is executed. I really wanted to emulate that the update button was hit. So -- is there a way to hit the enter button, and in the js code, mandate that it was the "update" button that was clicked? Thanks. This may be a stupid question, but is there a way to have a page refreshed at a specific time of day? I have made up a page I set as my browser's home page, an electronic Page-A-Day calendar. If I am working on the computer overnight I would like this page to refresh autotically at midnight. I have seen all sorts of posts that describe how to refresh after a certain amount of time has passed, but nothing for what I would like to do. For those interested the code i have for the webpage in in the attached file. Nite Hello everyone, I am completely new to javascripts. I want to have a count down timer on my webpage. I already found a script, but it does not do everything I want it to do. I couldn't find a script that did everything I need. I need it to do the following things: - Use the time zone GMT+1 - Reset everyday at a specific time - From 15:00 till 17:30: A countdown (so it shows 2 hours and 30 minutes from the start and count's down to 0 (which will be 17:30) - During 15:00 till 17:30 it shows: "The game is playing" - Once it is 17:30 I want it to reset and countdown till the next day 15:00 - From 17:30 till 15:00 next day it says: "The game will start in" So it is actually 2 countdown clocks in one javascript. One countdown from 15:00 to 17:30 (whilst the game is playing) and one directly starting after it from 17:30 till 15:00 next day. But both are displayed on the same spot. The countdown will be in text. No buttons or fancy images etc. Hope you can help me out. Thanks Code: <html> <head> <script type = "text/javascript"> function getSeconds() { var now = new Date(); var time = now.getTime(); // time now in milliseconds var midnight = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight 0000 hrs // midnight - change time hh,mm,ss to whatever time required, e.g. 7,50,0 (0750) var ft = midnight.getTime() + 86400000; // add one day var diff = ft - time; diff = parseInt(diff/1000); if (diff > 86400) {diff = diff - 86400} startTimer (diff); } var timeInSecs; var ticker; function startTimer(secs){ timeInSecs = parseInt(secs); ticker = setInterval("tick()",1000); tick(); // to start counter display right away } function tick() { var secs = timeInSecs; if (secs>0) { timeInSecs--; } else { clearInterval(ticker); // stop counting at zero //getSeconds(); // and start again if required } var hours= Math.floor(secs/3600); secs %= 3600; var mins = Math.floor(secs/60); secs %= 60; var result = ((hours < 10 ) ? "0" : "" ) + hours + " hours " + ( (mins < 10) ? "0" : "" ) + mins + " minutes " + ( (secs < 10) ? "0" : "" ) + secs + " seconds"; document.getElementById("countdown").innerHTML = "The game will start in " + result; } </script> </head> <body onload = "getSeconds()"> <span id="countdown" style="font-weight: bold;"></span> </body> </html> Reply With Quote 01-07-2015, 10:11 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts First of all, move your JavaScript where it belongs: Just before the </body> tag. Then you don't need stuff such as onload='....' Here's my attempt at it: Code: <!DOCTYP html> <html> <head> <title>Game play starts at 17:30</title> </head> <body> Other stuff...<br/><br/> <span id="countdown" style="font-weight: bold;"></span> <br/><br/>Other stuff...<br/><br/> <script type="text/javascript"> var timer = null; function tick( ) { var msg = document.getElementById("countdown"); var now = new Date(); var yr = now.getFullYear(); var mon = now.getMonth(); var dy = now.getDate(); var startat = new Date(yr,mon,dy,15,0,0); var endat = new Date(yr,mon,dy,17,30,0); if ( now.getTime() < startat.getTime() ) { msg.innerHTML = "The game will start at 17:30"; } else if ( now.getTime() > endat.getTime() ) { msg.innerHTML = "The game started at 17:30"; } else { var sec = Math.floor( ( endat.getTime() - now.getTime() ) / 1000 ); var min = Math.floor ( sec / 60 ); sec %= 60; var hr = Math.floor ( min / 60 ); min %= 60; if ( min < 10 ) min = "0" + min; if ( sec < 10 ) sec = "0" + sec; msg.innerHTML = "The game will start in " + hr + ":" + min + ":" + sec; } } tick(); // immediate start timer = setInterval( tick, 1000 ); // every second </script> </body> </html> How can I do this? I'm new to JavaScript. I tried messing with While but it just caused lag as it kept looping infinitely. The problem I think is that I have a variable that changes every time I click the button. The function changes the variable. So it successfully changes the variable once to my likings, then when I click the button (thus running the function) it does nothing. Here's an example I created to show you Quote: <html> <head> <script type="text/javascript"> var x = 50; var y = Math.floor(Math.random()*5); function test() { var a = x+y document.getElementById("testing").innerHTML=a; } </head> <body> <p id="testing"></p> <input type="button" value="asdf" onclick="test()" /> </body> </html> So in this case, I need to click the button multiple times in which each time it should add y to x. It only works once and then goes kaput. Thanks! Hello I am new to javascript (4 months), I would like to add an hour to the current time each time a button is clicked. I have this code: ------------------------------------------------------------------ var hourstbutton=document.getElementById("button3"); hoursbutton.onclick=function() { var divlink=document.getElementById("math3"); var newtime2=new Date(); var currenthours2=newtime2.getHours()+1; var currentmins2=newtime2.getMinutes(); var currentsecns2=newtime2.getSeconds(); var ampm2= (currenthours2>=12) ? "P.M." : "A.M."; if (currenthours2>=13) { currenthours2-=12; } if(currenthours2<1){ currenthours2=12; } if(currentmins2<10){ currentmins2= "0" + currentmins2; } if(currentsecns2<10){ currentsecns2="0" + currentsecns2; } divlink.innerHTML=currenthours2+":"+currentmins2+":"+currentsecns2+ " "+ampm2; ------------------------------------------------------------------------ How do I tie the number of button clicks into the number of times this code is executed? Any help is appreciated thanks. This is a general question on if it's possible and how I'd go about it... I'm working on a site hosted through a blog-managing company. Sometimes their programming doesn't seem to let me do things that would normally be possible, so I have to find creative work-arounds. This time, It doesn't seem I can use javascript to change an href destination that is generated by their system. I want the user to go to a different page, when they click on that link. I can have a script find a specific href, but it can't change it for some reason. So I'm wondering if there's a way I can just have the script redirect the user if they click on that link? I know it seems like a long way round, but I don't see any other way to do this under the circumstances. Just in case it helps, here's what I thought would work, but didn't: Code: document.getElementById('elementName').href == 'http://www.newURL.com'; A quick background into what Im trying to acheive. I have a link which is setup to redirect a phone to another number, this is something set up on our PBX. The link is something simple like Http://phones.company.com/forward?=4332 This aspect is fine, but authentication is required to get to this page, so I get redirected to a login screen. What I want to be able to do is bypass this screen, by somehow hardcoding the username and password, so that the form is submitted automatically and no user intervention is required. The code for the login screen is below. Is this possible?? Ive had a quick look for the obvious, but my javascript skills are poor. Maybe Im looking at this all wrong and there is a much easier way. Any suggestions would be appreciated. Code: <html><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Login</title> <!--------------------------------------------------------------------------> <!-- NLS area <!--------------------------------------------------------------------------> <link rel="stylesheet" type="text/css" href="req1_files/req.css"> <style type="text/css"> .getPos { position:relative; left:0; top:0; visibility:hide; visibility:hidden; } .setPos { position:absolute; left:0; top:0; visibility:hide; visibility:hidden; zIndex:1; font-family:"arial","helvetica"; font-size:10pt; } .userfield { width:180px; } .domain { width:120px; } #loginBtn { width:65px;height:25px; padding-top:4px; text-align:center; background-repeat:no-repeat; cursor:pointer;cursor:hand; } .loginBtnReleased { background-image:URL('../images/loginReleased.gif'); } .loginBtnPressed { background-image:URL('../images/loginPressed.gif'); } </style> <!----------------------------------------------------------------> <!-- Script area --> <!----------------------------------------------------------------> <script> /* layer.js - Accessing layers in a browser independent way */ var oldX; function show_layer(x) { if(document.getElementById) { if(document.getElementById(x) != null) document.getElementById(x).style.visibility="visible"; } else if(document.layers) { if( document.layers[x] != null ) document.layers[x].visibility="show"; } else if(document.all) { if( document.all[x] != null ) document.all[x].style.visibility="visible"; } } function hide_layer(x) { if(document.getElementById) { if(document.getElementById(x) != null) document.getElementById(x).style.visibility="hidden"; } else if(document.layers) { if( document.layers[x] != null ) document.layers[x].visibility="hide"; } else if(document.all) { if( document.all[x] != null ) document.all[x].style.visibility="hidden"; } } function checkLayerExists( x ) { if(document.getElementById) { if(document.getElementById(x) != null) return true; } else if(document.layers) { if( document.layers[x] != null ) return true; } else if(document.all) { if( document.all[x] != null ) return true; } return false; } function checkLayer( x ) { if(oldX && oldX!=x) { hide_layer(oldX); show_layer(x); oldX=x; } else if (!oldX && oldX!=x) { show_layer(x); oldX=x; } } function closeLayer(x) { hide_layer(x); oldX=null; } function getForm( layer, form ) { var myForm = null; if(document.getElementById) { myForm = document.forms[form]; } else if(document.layers) { var myLayer = document.layers[layer]; if( myLayer != null ) myForm = myLayer.document.forms[form]; } else if(document.all) { myForm = document.forms[form]; } return myForm; } function getFormElement( layer, form, element ) { var myForm = getForm( layer, form ); if( myForm != null ) return myForm[element]; else return null; } </script> <script> /* focushandler.js - handling of focus in input forms */ /* This focus handler sets the focus to the first empty input text field at the beginning and to the next empty text field by entering CR or invoking submit. If all fields are set and CR was entered in one of the text fields, the submit function will be called automatically. */ var myFocusHandlerForm = null; /* only one form for focus handling is supported */ var myAutoSubmit = true; /* invoking submit by CR if all fields are set */ var myAutoSubmitHandler = null; /* invoking this handler */ function initFocusHandler(formName) { initFocusHandlerExt(formName, (document.layers != null)); } function initFocusHandlerExt(formName, chkCR) { var form = document.forms[formName]; var setDone = false; myFocusHandlerForm = form; for( var i=0, len = form.elements.length; i < len; i++ ) { var e = form.elements[i]; if( (e.type == "text" || e.type == "password") ) { if( !setDone && e.value == "" ) { e.focus( ); /* set focus to first field */ setDone = true; } if( chkCR ) e.onkeydown = checkCR; /* establish CR recognizer */ } } } function setAutoSubmit( enabled ) { myAutoSubmit = enabled; } function setAutoSubmitHandler( handler ) { myAutoSubmitHandler = handler; } function checkCR(e) { var key = (document.layers) ? e.which : (document.all) ? window.event.keyCode : e.keyCode; if( key == 13 ) { var form = myFocusHandlerForm; if( verifyInput(form) && myAutoSubmit ) { if( myAutoSubmitHandler != null ) myAutoSubmitHandler(form); else form.submit(); } } return true; } function verifyInput(form) { for( var i=0, len=form.elements.length; i < len; i++ ) { var e = form.elements[i]; if( (e.type == "text" || e.type == "password") && (e.value == null || e.value == "") ) { form.elements[i].focus(); /* set focus to empty field */ return false; } } return true; /* all are set */ } </script> <script> /* popuphandler.js - handling of popup menus by layers */ var myPopupLayer = new Array(); var myPopupWidth = new Array(); var myPopupByEvent = ""; var myPosByEvent = false; var myPosY = 0; if( document.all ) document.onmousedown = setPosY; function initPopupHandler( popupLayer, popupWidth ) { document.onmouseup = hidePopupAll; var newIndex = myPopupLayer.length; myPopupLayer[newIndex] = popupLayer; myPopupWidth[newIndex] = popupWidth; } function updatePopupWidth( popupLayer, popupWidth ) { var index = getPopupIndex( popupLayer ); myPopupWidth[index] = popupWidth; } function showPopup( posLayer ) { var index = 0; /* suppose only one layer to popup was defined */ var popupLayer = myPopupLayer[index]; var popupWidth = Math.abs(myPopupWidth[index]); showPopupLayer( popupLayer, posLayer, (-popupWidth) + 6, 4 ); } function showPopupLeftAt( popupLayer, posLayer, offsetX, offsetY ) { var index = getPopupIndex( popupLayer ); var popupWidth = Math.abs(myPopupWidth[index]); showPopupLayer( popupLayer, posLayer, (-popupWidth) + offsetX, offsetY ); } function showPopupLayer( popupLayer, posLayer, offsetX, offsetY ) { if(document.getElementById) { var posX = getPopupPositionX( posLayer ); var posY = getPopupPositionY( posLayer ); setPopupPosition( popupLayer, posX + offsetX, posY + offsetY ); document.getElementById(popupLayer).style.visibility="visible"; } else if( document.layers) { var posX = getPopupPositionX( posLayer ); var posY = getPopupPositionY( posLayer ); setPopupPosition( popupLayer, posX + offsetX, posY + offsetY ); document.layers[popupLayer].visibility = "show"; } else if(document.all) { if( !myPosByEvent ) { var posX = getPopupPositionX( posLayer ); var posY = getPopupPositionY( posLayer ); setPopupPosition( popupLayer, posX + offsetX, posY + offsetY ); } document.all[popupLayer].style.visibility = "visible"; } } function isPopupVisible( popupLayer ) { if(document.getElementById) return (document.getElementById(popupLayer).style.visibility == "visible"); else if(document.layers) return (document.layers[popupLayer].visibility == "show"); else if(document.all) return (document.all[popupLayer].style.visibility == "visible"); } function setPopupVisible( popupLayer, visible ) { if(document.getElementById) { if( visible ) document.getElementById(popupLayer).style.visibility = "visible"; else document.getElementById(popupLayer).style.visibility = "hidden"; } else if(document.layers) { if( visible ) document.layers[popupLayer].visibility = "show"; else document.layers[popupLayer].visibility = "hide"; } else if(document.all) { if( visible ) document.all[popupLayer].style.visibility = "visible"; else document.all[popupLayer].style.visibility = "hidden"; } } function getPopupIndex( popupLayer ) { for( var i = 0; i < myPopupLayer; i++ ) if( myPopupLayer[i] == popupLayer ) return i; return 0; } function setPopupPosition( popupLayer, posX, posY ) { if(document.getElementById) { document.getElementById(popupLayer).style.left = posX; document.getElementById(popupLayer).style.top = posY; } else if(document.layers) { document.layers[popupLayer].pageX = posX; document.layers[popupLayer].pageY = posY; } else if(document.all) { document.all[popupLayer].style.left = posX; document.all[popupLayer].style.top = posY; } } function getPopupPositionX( posLayer ) { if(document.getElementById) { var elm = document.getElementById(posLayer); var pos = document.getElementById(posLayer).offsetLeft; if( pos <= 15 ) { while ( elm != null ) { pos += elm.offsetLeft; elm = elm.offsetParent; } } return pos; } else if(document.layers) return (document.layers[posLayer].pageX); else if(document.all) { var elm = document.all[posLayer]; var pos = document.all[posLayer].offsetLeft; if( pos <= 15 ) /* IE.5.0 bug: adding padding to offset */ { while ( elm != null ) { pos += elm.offsetLeft; elm = elm.offsetParent; } } return pos; } } function getPopupPositionY( posLayer ) { if(document.getElementById) { var elm = document.getElementById(posLayer); var pos = document.getElementById(posLayer).offsetTop; if( pos <= 15 ) /* IE.5.0 bug: adding padding to offset */ { pos = -6; while ( elm != null ) { pos += elm.offsetTop; elm = elm.offsetParent; } } else if(document.all) { var posDiff = (pos > myPosY) ? pos - myPosY : myPosY - pos; if( posDiff < 20 ) /* IE.6.0 bug: cumulative patch */ pos -= 15; else pos = (pos/2); var tableOffset = 2; var a = window.document.all; for( var i=0; i < a.length; i++) { if( a[i].name == "maintable" ) { tableOffset = (a[i].offsetTop / 2) - 1; break; } } pos += tableOffset; } return pos; } else if(document.layers) return (document.layers[posLayer].pageY); else if(document.all) { var elm = document.all[posLayer]; var pos = document.all[posLayer].offsetTop; if( pos <= 15 ) /* IE.5.0 bug: adding padding to offset */ { pos = -6; while ( elm != null ) { pos += elm.offsetTop; elm = elm.offsetParent; } } else { pos = (pos/2); var tableOffset = 2; var a = window.document.all; for( var i=0; i < a.length; i++) { if( a[i].name == "maintable" ) { tableOffset = (a[i].offsetTop / 2) - 1; break; } } pos += tableOffset; } return pos; } } function enablePopupByEvent( popupLayer, enable ) { myPopupByEvent = popupLayer; myPosByEvent = enable; } function setPopupPosByEvent(e) { if( myPosByEvent && document.layers == null && document.all ) { if( document.all[myPopupByEvent] != null ) { var ev = window.event; var posX = ev.clientX - ev.offsetX - 2 - myPopupWidth; var posY = ev.clientY - ev.offsetY + 6; setPopupPosition( myPopupByEvent, posX, posY ); } } return true; } function setPosY(e) { myPosY = window.event.clientY + document.body.scrollTop; return false; } function hidePopupAll(e) { hidePopup(); } function hidePopup() { for( var i = 0; i < myPopupLayer.length; i++ ) hidePopupLayer( myPopupLayer[i] ); } function hidePopupLayer( popupLayer ) { if(document.getElementById) { if(document.getElementById(popupLayer) != null) document.getElementById(popupLayer).style.visibility = "hidden"; } else if(document.layers) { document.layers[popupLayer].visibility = "hide"; } else if(document.all) { if( document.all[popupLayer] != null ) document.all[popupLayer].style.visibility = "hidden"; } } </script> <script> /* utilscript.js - extended string functions, etc. */ function checkChars( chkStr ) { chkStr = escape(chkStr); /* special handling for phone numbers */ for( ; (i = chkStr.indexOf('+')) >= 0; ) { var s = (i > 0) ? chkStr.substring( 0, i ) + "%2B" : "%2B"; chkStr = s + chkStr.substring( i+1, chkStr.length ); } return chkStr; } function trimString( str ) { return removeTrailingBlanks( removeLeadingBlanks( str ) ); } function removeLeadingBlanks( str ) { while( str.length > 0 && str.charAt( 0 ) == ' ' ) str = str.substr( 1, str.length - 1 ); return str; } function removeTrailingBlanks( str ) { while( str.length > 0 && str.charAt( str.length - 1 ) == ' ' ) str = str.substr( 0, str.length - 1 ); return str; } </script> <script language="JavaScript"> function init() { initFocusHandlerExt("doLogin",false); setAutoSubmitHandler( sendFormHandler ); setLastUser( "", "" ); } function doSendForm() { var form = document.doLogin; var check = false; var pwdforgotten = false; if (pwdforgotten) { if (verifyUser()) check = true; } else { if( verifyInput( form ) ) check = true; } if (check) sendFormHandler( form, pwdforgotten ); return true; } function verifyUser () { var user = document.forms.doLogin.j_username.value if (user == "" || user.length == 0) { document.forms.doLogin.j_username.focus(); return false; } return true; } function sendFormHandler( form, pwdforgotten) { var sendForm = document.forms.sendLogin; var user = document.forms.doLogin.j_username.value; var passwd = document.forms.doLogin.j_password.value; var domainList = document.forms.doLogin.j_domain; var index = domainList.selectedIndex; var authMode = (index >= 0) ? domainList.options[index].value : "TELAS"; if( authMode == "" ) { alert( "Please enter the name of your windows domain" ); return; } if( index >= 0 ) { var domain = domainList.options[index].value; if (domain != "TELAS") user = domain + "\\" + user; sendForm.authMode.value = authMode; } else { sendForm.authMode.value = "TELAS"; } // fill hidden form to send request sendForm.j_username.value = user; sendForm.j_password.value = passwd; if (pwdforgotten) sendForm.j_pwdforgotten.value = "forgotten"; sendForm.submit(); } function setLastUser( user, wrongpwd ) { if( user != "" ) { var i = user.indexOf( '\\' ); if( i > 0 ) { var domainList = document.forms.doLogin.j_domain; var domainIndex = -1; var domain; domain = user.substring( 0, i ); user = user.substring( i + 1, user.length ); for( i = 0; i < domainList.options.length; i++ ) { var value = domainList.options[i].value; if( value == domain ) { domainIndex = i; break; } } if( domainIndex >= 0 ) domainList.selectedIndex = domainIndex; } document.forms.doLogin.j_username.value = user; if( wrongpwd ) document.forms.doLogin.j_password.focus(); } } function doSendPassword() { var request = "/tweb/login/req?pwdForgotten="; var user = document.doLogin.j_username.value; request = request + "&authuser=" + user; window.location.href = request; } </script> </head><body class="common" onload="init();"> <p> </p> <div align="center"><center> <form name="doLogin" action="javascript:(void 0);" onsubmit="verifyInput(this); return false;"> <!---------------- login dialog for an user session --------------------> <noscript> <font color=red>To use ComAssistant CTI<br>you must activate JavaScript at first.</font><p> </noscript> <table class="frame" border="1" cellpadding="4" cellspacing="0"> <tbody><tr><td class="caption" align="center"><b>ComAssistant CTI</b></td></tr> <tr><td class="light" valign="middle" align="center"> <table border="0" cellpadding="0" cellspacing="8"> <!------------------------------------ user ------------------------> <tbody><tr> <td> </td> <td class="dialog" align="left">User name:</td> <td class="dialog"><input value="5255" class="userfield" size="18" maxlength="64" name="j_username" width="180px"></td> <td> </td> </tr> <!------------------------------------ domain ------------------------> <tr> <td> </td> <td class="dialog" align="left">Password:</td> <td class="light"><input class="userfield" size="18" maxlength="32" name="j_password" width="180px" type="password"></td> <td> </td> </tr> <tr> </tr><tr> <td> </td> <td class="dialog" align="left">Domain:</td> <td class="light" align="right"> <select class="light" width="180" name="j_domain"> <option selected="selected" value="CAPLogin\XXXXX">XXXX</option> <option value="CAPLogin\">CTI Authentication</option> </select> </td> <td valign="top"><div id="editDomainPos" class="getPos"> </div></td> </tr> <tr><td> </td> <!------------------------------------ password forgotten ------------------------> <td> </td> <!------------------------------------ OK ----------------------------------------> <td class="title-light" align="right"> <input value="OK" onclick="return doSendForm();" width="100" type="submit"> </td> <td> </td> </tr> </tbody></table> </td></tr> </tbody></table> </form> <!------------------ form sended to servlet ------------------------> <form name="sendLogin" method="GET" action="https://xxxxx.xxx.xx:xxx/tweb/j_security_check;jsessionid=B9CB670DB13E02625B197D382750FC38"> <input name="j_username" value="" type="hidden"> <input name="j_password" value="" type="hidden"> <input name="j_pwdforgotten" value="" type="hidden"> <input name="authMode" value="" type="hidden"> <input name="origReq" value="/tweb/portal/req?getPage=/userindex.html" type="hidden"> </form> <!------------------------------------------------------------------> </center></div> </body></html> I am a new to js and GM but I am trying to make a script that will click a button on a page where there are multiple instances of the button. The source I am looking at is below and I have narrowed down what I am looking at to the bold section. <dl> <dd class="left"><div id='recommendstatus_article4458331'> <dl class="recommend"> <dt class='recs'><a href="javascript://" onclick="RecSpy( 'article', '4458331', 'tippers' ); return false;">50</a> </dt> <dd><a href="javascript:void(0);" onclick="RecommendItem(1,'article','4458331','1','recommendstatus_article4458331' ); return false;" onmouseover="return overlib('Give thumbs up', WRAP);" onmouseout="return nd();"> <img class='icon' title='' alt='Thumb up' style='background-position: -304px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a></dd> <dt class='tippers'><a href="javascript://" style='color: #969600;' onclick="RecSpy( 'article', '4458331', 'tippers' ); return false;"></a></dt> <dd><a href="javascript:void(0);" onmouseover = "return overlib( 'GeekGold Tip', WRAP );" onmouseout = "nd();" onClick="GeekGoldTip(0,'article','4458331','recommendstatus_article4458331'); return false;"> <img class='icon' title='' alt='tip' style='background-position: -368px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a></dd> <dd> <a href="javascript:void(0);" onclick="RecommendItem(0,'article','4458331','','recommendstatus_article4458331', 'article4458331' ); return false;" onmouseover="return overlib('Hide this post', WRAP);" onmouseout="return nd();"> <img class='icon' title='' alt='Thumb up' style='background-position: -336px -48px;' src='http://geekdo-images.com/images/pixel.gif' /></a> </dd> <dt class='thumbsdown'> </dt> </dl> How do I create a script to find each instance of the button and click it? Another thing that has been driving me crazy is that css positioning is handled differently by different browsers. JS is not my area, but I can do a lot with CSS, and I do, but cross browser compatibility is killing me. I can use an IF IE statement and only IE runs that segment of code, but I haven't been able to figure out out how to make ONLY firefox or ONLY opera or safari enact an encapsulated segment of code. The same type of IF statement doesn't work for them. Is there a single method using JS that works for all browsers? Thre is probably a very simple answer and I am just missing it somehow. Hi Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } alert(err-str); here ind==1 is from_time and ind==2 is to_time,i need to validate time as to_time must be always greater than from-time,if condition fails an alert msg should populate.time format is[05:00]as it is in string format im unable to do the validation for it.(ex:from-time=08:00 to-time=07:59 condition fails) thank you. hi im using dhtml xgrid where i need to do validation for time ,(from-time and to-time i.e ind==1 and ind==2 ) to-time must be greater than from-time else i need to alert a message to-time must be greater than from-time. can any one send me the code for it time format is[05:00]. Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } Hello im using dhtmlx grid in this cells i have from time and to time (i.e ind==1 and ind==2) i need to validate time where to-time must be greater than from-time else it should alert an message,i have writeen a normal Regular expression for the time validation.as the time is i string format i.e[05:00],please can any one send me code for that. Code: var err_str=""; function validate_grid(value,id,ind) { if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } Ok know those people who are in the bad habit of double clicking everything? Well my site breaks if they double click it... is there a script I can use that won't let my functions run more then once every so many seconds? to avoid double clicking errors? 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help I'm not really a Java writer, so I don't know how to do this myself, though I imagine it would be pretty simple. I am looking to add a script to a webpage that allows users to input a time manually, and have it converted to GMT/Zulu time and display the converted time. I have seen a lot of time zone conversion scripts online, but they all just convert whatever the current system time is to another time zone. I am looking for a script that allows users to convert a time and show the zulu time, for times other than the current time. The time zone the inputed local time would be in is +4:30 (Kabul). I don't really care about style or aestehtics, just a simple script I can insert into a web page to have a time input field. The converted output time can appear in another field, a popup bubble, etc, again style isn't really an issue. It's really just to help people in my job who need to know what the GMT/Zulu time was for certain local times after the fact. One would think it shouldn't be that hard to just subtract 4:30 in your head, but apparently it is. Sorry if just asking for code outright like this is frowned upon. hi, can some one help me how to get the time and date difference? given two time and date with the following format like in textbox A: 2011-05-03 17:35:47.0 and textbox B: 2011-05-03 16:35:47.0 then the output would be: 0 days, 1 hour, 0 minutes, 0 seconds regards, verve Hey guys just need a little help. I need to create a little script that clicks a link automatically and opens it up in a new page. So far I have this: Code: <head> <script> function autoClick(){ document.getElementById('linkToClick').click(); } </head> <body onload="setTimeout('autoClick();',3000);"> <a id="linkToClick" href="http://www.google.com" rel="nofollow" target="_blank">GOOGLE</a> </body> It works but the problem is that IE popup blocker keeps blocking the new window. Is there a way to do the same thing with javascript without it having blocked by IE popup blocker? This is my first time doing JavaScript I don't what I did wrong here, but the problem its not showing up the current date and time. Code: <script language = "JavaScript" type="text/javascript"> now = new Date(); localtime = now.toString(); utctime = now.GMTString(); document.wite("<b>localtime</b>" + localtime + "</br>"); document.write("<b>utctime</b>" + utctime); </script> This is what supposed to look like I have tried using different browser chrome,IE9,Maxtor, and Opera my OS is Win7 need to make "left click" act as "middle click" -------------------------------------------------------------------------------- I need to make "left click" act as "middle click" for a web site ....thank you in advance for any and all help... [CODE] <script language="javascript"> function Click(4) { if (event.button==0; 1; ) } document.onmousedown </script>> Hi I have created the following effects on the images seen here http://techavid.com/design/test3.html . You see when you hover and then click on each image, they go from grey to color. When you click on one - the others go grey and the one clicked remains color. That's cool, but now I need the text 1st: Sun for example to display and hide along with its graphic button. The word "Sun," is a link that needs to link out to a URL so it has to be separated from the image effect code. Here code I have now.... Code: <style type="text/css" media="screen"> #wrapper { background: url('_assets/images/sun-inactive.p') no-repeat #777eee; width: 470px; margin: 0 auto; } a#sun{ background: url('_assets/images/sun-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#sun:hover, a#sun.active { background: url('_assets/images/sun.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } a#plane { background: url('_assets/images/plane-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#plane:hover, a#plane.active { background: url('_assets/images/plane.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } a#nano { background: url('_assets/images/nano-inactive.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; float: left; } a#nano:hover, a#nano.active { background: url('_assets/images/nano.png') no-repeat; width: 107px; height: 78px; display:block; padding: 20px 10px; } #popuptext { float: left; margin: -30px 0 0 0; padding: 0 0 0 0px; font-size: 11px; } #popuptext a { color: #ff6600; padding: 0 30px; } </style> </head> <body> <div id="wrapper"> <div id="navigation"> <a id="sun" href="#"></a> <a id="plane" href="#"></a> <a id="nano" href="#"></a> </div> <div style="clear:both"></div> <div id="popuptext">1st: <a href="#">Sun</a> 2nd: <a href="#">Airplane</a> 3rd: <a href="#">Nano</a> </div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function() { // target each link in the navigation div $('#navigation a').click(function() { // link that you clicked clicked = $(this).attr('id'); // make sure that all the others are not active // except for the clicked one $('#navigation a').each(function() { if ($(this).attr('id') == clicked) { $(this).addClass('active'); } else { $(this).removeClass('active'); } }); // prevent the default link action return false; }); }); </script> What jquery or javascript code do I need to do this? thanks, chaser |