This is a javascript, I have no experience in coding unfortunately. So I need your help.   I'm trying to put a 10 sec delay on this code  document.getElementById('example').click();   The idea is that I want a link to be click after 10 secs.   I tried putting 10000); at the end of the code but it makes the code not work.  How can I make this code do what I want?
30980
Is there any JavaScript method similar to the jQuery delay() or wait() (to delay the execution of a script for a specific amount of time)?
113150
I'm making an HTML 5 game. I want mouse clicks on sprites drawn in a canvas element cause events that my code can react to. At the moment, I'm doing it by checking through all of my sprites in a for-loop on each click.  Is there a way to do that by adding an event listener to a sprite so it would respond just like that?  Are Javascript's custom events useful in this situation? I know it's possible with KinectJS, but I don't have any experience with it and really I'd like to learn how to do this myself without the help of a library.
100318
I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created.    How can I make the dialog box show something like this:  There was an error.  Go to this page to fix it. wwww.TheWebPageToFix.com    Thanks.
50397
I have searched the web but all the ones readily available are where you specificy a date and it counts down to that date. What I need is something which will simply count down from "27 minutes and 43 seconds" (in that format) all the way down to 0 from whenever they land on the page, anyone got any snippets available?
118832
I've got an issue. When (Input.GetMouseButtonUp (0), Speedy script is disabled, thus we cannot enable it again from inside the script like shown below. How can we go around this?  public class  Speedy : MonoBehaviour {  GameObject car;   if (speed == good)     {         GameObject car = GameObject.FindWithTag ("Car");          if (Input.GetMouseButtonUp (0))          {             car.GetComponent&lt;Speedy&gt;().enabled = false;         }          else car.GetComponent&lt;Speedy&gt;().enabled = true;     } }
31380
Many times I've seen links like these in HTML pages:  &lt;a href='#' onclick='someFunc(3.1415926); return false;'&gt;Click here !&lt;/a&gt;   What's the effect of the return false in there?  Also, I don't usually see that in buttons.  Is this specified anywhere? In some spec in w3.org?
13889
This is the second mouse dying on me because of a poor switch ! Under most operating systems there is a option to set the max time interval in which two mouse clicks are processed as on double click.  Logically there has to be a way to set a minimum double click time interval!  I surely could replace the broken switch but there are costs for the new switch, time and basic soldering needed for that. Obviously this should be the last possible step to take.  Firstly I want to try to let the computer handle the broken mouse. I am searching a fix for windows and especially for linux (ubuntu) systems.  E: as Matt Eckert mentioned the problem is that the mouse switch is gotten loose and is producing two signals with just one key press. I've never mentioned that I want to set up anything within th mouse. Sorry for the misunderstanding, I thought that this problem occurs very often so that everyone understands the problem with the give information.  Under Windows there is only the option to set the maximum time interval in in which a double click is recognized. I need to set up the minimum time interval. In other word a double click should only be recognized if the time difference between two mouse clicks is at least for example half of a millisecond.
77576
I want to click on something for hours. How can I make a script or use an application so the mouse will auto-click every 5 seconds or less?
42370
What is the most recommended/best way to stop multiple instances of a setTimeout function from being created (in javascript)?  An example (psuedo code):  function mouseClick() {    moveDiv("div_0001", mouseX, mouseY); }  function moveDiv(objID, destX, destY) {    //some code that moves the div closer to destination    ...    ...    ...     setTimeout("moveDiv(objID, destX, destY)", 1000);    ...    ...    ... }   My issue is that if the user clicks the mouse multiple times, I have multiple instances of moveDiv() getting called.  The option I have seen is to create a flag, that only allows the timeout to be called if no other instance is available...is that the best way to go?  I hope that makes it clear....
96230
How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time.  Edit: These users do want to be distracted when a new message arrives.
4059
The situation is somewhat like-  var someVar = some_other_function(); someObj.addEventListener("click", function(){     some_function(someVar); }, false);   The problem is that the value of someVar is not visible inside the listener function of the addEventListener, where it is probably being treated as a new variable.
37689
We are using jQuery  to dynamically display an iframe when someone clicks on a picture.  In this iframe, we are using  a javascript library to display multiple pictures.  The problem seems to be that $(document).ready in the iframe seems to be fired too soon and the iframe content isn't even loaded yet, so galleria code is not applied properly on the DOM elements.  $(document).ready seems to use the iframe parent ready state to decide if the iframe is ready.  If we extract the function called by document ready in a separate function and call it after a timeout of 100&nbsp;ms. It works, but we can't take the chance in production with a slow computer.  $(document).ready(function() { setTimeout(ApplyGalleria, 100); });   My question: which jQuery event should we bind to to be able to execute our code when the dynamic iframe is ready and not just it's a parent?
27396
The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.?    function myJsFunc() {     alert("myJsFunc"); } &lt;a href="#" onclick="myJsFunc();"&gt;Run JavaScript Code&lt;/a&gt;     or    function myJsFunc() {     alert("myJsFunc"); }  &lt;a href="javascript:void(0)" onclick="myJsFunc();"&gt;Run JavaScript Code&lt;/a&gt;
10439
I need to use a JavaScript patch in my Google Sites, but the problem is I don't understand how to place them and use it as Google Gadget.  &lt;!DOCTYPE &lt;strong class="highlight"&gt;html&lt;/strong&gt; PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;&lt;strong class="highlight"&gt;html&lt;/strong&gt; xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script language="javascript" type="text/javascript"&gt; var timerid = 0; var &lt;strong class="highlight"&gt;images&lt;/strong&gt; = new Array(  "image1.jpg",             "image2.jpg",             "image3.jpg"); var countimages = 0; function startTime() {     if(timerid)     {         timerid = 0;     }     var tDate = new Date();      if(countimages == &lt;strong class="highlight"&gt;images&lt;/strong&gt;.length)     {         countimages = 0;     }     if(tDate.getSeconds() % 5 == 0)     {         document.getElementById("img1").src = &lt;strong class="highlight"&gt;images&lt;/strong&gt;[countimages];     }     countimages++;      timerid = setTimeout("startTime()", 1000); } &lt;/script&gt; &lt;/head&gt;  &lt;body onload="startTime();"&gt; &lt;img id="img1" src="image3.jpg" /&gt; &lt;/body&gt; &lt;/html&gt;   I'm hoping for specific instructions using the JavaScript code I provided since I've found general Google Sites embedding instructions unfathomable. However with specific instructions I will be able to figure out how to use scripts in Google Sites in the future as well.
75671
I have a document library where the CEO wants to see three buttons. If he has read the document he wants to click on Yes, otherwise it will always be No. If he clicks Flag it means it needs to be discussed. How can I have three buttons where he can simply push it and he wants that to be color coded. He is using safari on ipad and would not change that; therefore all the easy options I had for him are not going to help . Is there a javascript I can use so when he clicks the Yes button it turns green and when he clicks No it remains red. I have searched everywhere for an answer and I can't find one. I am not good at coding and just a beginner so still learning but this one is becoming a hard task doesn't seem hard but for me it is.   He does not want to go into edit view to complete the task as he says its too many clicks and of course since its its on ipad it is bit harder than working a computer.  I am thinking of adding one button with three colors, First one will always be no so red and onclick it will become green and if he clicks it again it will become black. Is there a javascript that can add a button in a column and have the user just click on it with their mouse and no editing required?   Thanks in Advance.
44255
I am trying to insert a chunk of HTML into a div. I want to see if plain JavaScript way is faster than using jQuery. Unfortunately, I forgot how to do it the 'old' way. :P  var test2 = function(){     var cb = function(html){         var t1 = document.getElementById("test2");         var d = document.createElement("div");         d.id ="oiio";         d.innerHtml = html;         t1.appendChild(d);         console.timeEnd("load data with javascript");     };     console.time("load data with javascript");     $.get("test1.html", cb); }   what am i doing wrong here guys?  edit:  Someone asked which is faster, jquery or plain js so i wrote up a test:   plain js is 10% faster
7437
I have a method that uses the  function and makes a call to another method. On initial load method 2 works fine. However, after the timeout, I get an error that says method2 is undefined. What am I doing wrong here?  ex:  test.prototype.method = function() {     //method2 returns image based on the id passed     this.method2('useSomeElement').src = "http://www.some.url";     timeDelay = window.setTimeout(this.method, 5000); };  test.prototype.method2 = function(name) {     for (var i = 0; i &lt; document.images.length; i++) {         if (document.images[i].id.indexOf(name) &gt; 1) {             return document.images[i];         }     } };