I have simple javascript alert box i want it to close automatically after 5 second. if possible help please.  &lt;script type="text/javascript"&gt; function show_alert() { alert("Hello! I am an alert box!"); } &lt;/script&gt;  &lt;input type="button" onclick="show_alert()" value="Show alert box" /&gt;
83075
I want to be able to close an alert box automatically using Javascript after a certain amount of time or on a specific event (i.e. onkeypress).  From my research, it doesn't look like that's possible with the built-in alert() function.  Is there a way to override it and have control over the dialog box that it opens?  Also, I don't want an override that shows a hidden div as the alert.  I need an actual dialog box.
60241
What is the best way to close an ASPX page from the code-behind?    I have a button event handler that I want to close the page after the user has clicked an ASP.NET button on the page.  I have tried to programmatically add a JavaScript method that contains a window.close() command to the OnClientClick event to close the page but it does not work.  The button is also a asp:AsyncPostBoskTrigger for an AJAX Update Panel.  The application uses .NET Framework 3.5.
123430
I would like to change the timer on the "The system will power off automatically in 60 seconds" dialog. The battery on my device dies about 30 seconds into this message.   There doesn't seem to be a setting for this in the usual places (gsettings, dconf, system settings, etc).  I am not interested in removing this dialog or changing the shutdown behavior, I just want to change the amount of time that it waits.
124177
Yes, I know the topic has been discussed before. I know that Meta already has threads that complain about how flagging doesn't work. I wanted to give a practical example.  Today, a  came in to the  chat and asked the :  Hey guys, as soon as I embed javascript, all my html elements are gone. Even if the script is empty!? ...Can anyone help out? The example is really minimalistic &lt;script type='text/javascript' src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js&quot;/&gt; &lt;script type='text/javascript' src=&quot;script.js&quot;/&gt; These lines make everything vanish. script.js is empty! I use google chrome and the file is on localhost  Some context:  The JS room encourages people to come and ask questions that are too small/badly put for main. The room encourages people to just ask questions rather than ask to ask. In fact we even have a bot that prompts users to just ask if they have a question whenever they join. The above user has a good Q to A ratio having 1K rep in the main site and over 80 answers. The user has no negative context in the chat. No previous offenses or anything like that.  That message got 7 flags  Had a mod (ThiefMaster) not been present and invalidated those flags in time that user would have probably been suspended from the chat. This is bad, it sends the wrong message and it is very rude. Now, some other rooms don't allow people to just come and ask questions right away so maybe users from other rooms validated the flag. Maybe users thought he was being rude? I don't know. I do know that we don't want this sort of negative atmosphere in the JS room (and I'm sure other useful rooms such as PHP don't want it either), we have enough on our hands trying to maintain a community while helping people joining and handing with vamps/trolls. Possible solutions:  Drop spam/offensive flags altogether. Make spam/offensive flags room specific for big enough (tm) rooms. Give room owners just the ability to invalidate spam/offensive flags.
53111
Because of , clicking the "close" link on a question that's been edited (for me usually the edit comes in a half-second before, as I'm reaching for the link) reloads the question instead of opening the Close dialog. Clicking it again to actually open the close dialog says     You may only open the Close dialog every three seconds   I didn't open it, I refreshed the post.  And yes, there are lots of times when the post edit is so trivial it's obvious in less than a second that it doesn't affect the need to close the question.
46363
What is the proper way to terminate a Swing application from the code, and what are the pitfalls?  I'd tried to close my application automatically after a timer fires. But just calling dispose() on the JFrame didn't do the trick - the window vanished but the application did not terminate. However when closing the window with the close button, the application does terminate. What should I do?
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)?
73601
I have a simple launchd script that plays a sound every 30 minutes and it runs out of the user library ~/Library . It doesn't run if my machine is asleep, but does run the last event missed when the machine wakes. I think this is the expected behavior. My question is, how do I stop this happening. If I missed the half-hour event, I don't want it to be run at 20 minutes past the hour.  Here's the core of my script. It calls a Python script. I tried to put a block in the python script to check that I am within a few minutes of each 30 minutes, but that doesn't seem to work on wake. (Is it missing the system clock somehow?)  &lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt;     &lt;string&gt;/usr/local/bin/python3&lt;/string&gt;     &lt;string&gt;/Users/pheon/Documents/playsound.py&lt;/string&gt; &lt;/array&gt;  &lt;key&gt;StartCalendarInterval&lt;/key&gt; &lt;array&gt;     &lt;dict&gt;         &lt;key&gt;Minute&lt;/key&gt;         &lt;integer&gt;0&lt;/integer&gt;     &lt;dict&gt;         &lt;key&gt;Minute&lt;/key&gt;         &lt;integer&gt;30&lt;/integer&gt;     &lt;/dict&gt; &lt;/array&gt;   Here is a snippet from the python code which checks the time before playing the sound.  time0 = datetime.datetime.now() if (time0.minute % 30) &lt; 2:     subprocess.run(["/Users/pheon/bin/afplay-vol.sh", "1", bell],check=True)
17965
I need to prevent accidental clicks in the Save button when a node is being saved.  I found this   which does exactly this. But the problem is that it uses javascript (jquery). Then if the user disable javascript this module is useless.  My problem is that in my website the user get points when creating nodes, so I have to prevent this in a more secure way.  How can I do this?   What do you think of these ideas?:  1) Maybe I would forbid the node being saved more than one time    programmatically instead of disabling the Save button.   2) Or better: I would allow the user to just save a new node every 5 minutes.
57212
I hate the new popup "you can accept an answer in 10 minutes". Can you please remove it and let me accept an answer immediately?  I can unaccept it later if a better one appears.
31937
Suppose to have this shortcode:  [spu-close class="" text="" align=""]   I want to show this short code when I click on a button this is  my html:   &lt;input class="button b" onclick="openFile(link);"  type="button" value="download" /&gt;   and this is my js file:  function openFile(link){ //I want do something like this     do_shortcode('[spu-close class="" text="" align=""]', false );    //    }   I don't know how I can do this, anyone can help me?
44387
I am looking for good ideas for implementing a generic way to have a single line (or anonymous delegate) of code execute with a timeout.  TemperamentalClass tc = new TemperamentalClass(); tc.DoSomething();  // normally runs in 30 sec.  Want to error at 1 min   I'm looking for a solution that can elegantly be implemented in many places where my code interacts with temperamental code (that I can't change).  In addition, I would like to have the offending "timed out" code stopped from executing further if possible.
12181
Is there a best-practice or common way in JavaScript to have class members as event handlers?  Consider the following simple example:  &lt;head&gt;     &lt;script language="javascript" type="text/javascript"&gt;          ClickCounter = function(buttonId) {             this._clickCount = 0;             document.getElementById(buttonId).onclick = this.buttonClicked;         }          ClickCounter.prototype = {             buttonClicked: function() {                 this._clickCount++;                 alert('the button was clicked ' + this._clickCount + ' times');             }         }      &lt;/script&gt; &lt;/head&gt; &lt;body&gt;     &lt;input type="button" id="btn1" value="Click me" /&gt;     &lt;script language="javascript" type="text/javascript"&gt;         var btn1counter = new ClickCounter('btn1');     &lt;/script&gt; &lt;/body&gt;   The event handler buttonClicked gets called, but the _clickCount member is inaccessible, or this points to some other object.  Any good tips/articles/resources about this kind of problems?
27357
In my experience, input type="text" onchange event usually occurs only after you leave (blur) the control.  Is there a way to force browser to trigger onchange every time textfield content changes? If not, what is the most elegant way to track this “manually”?  Using onkey* events is not reliable, since you can right-click the field and choose Paste, and this will change the field without any keyboard input.  Is setTimeout the only way?.. Ugly :-)
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?
56204
I am more used to the Javascript style event handlers,  but is there a similar thing in applescript that listens to system events like logout or shutdown to execute code  or is there a way to have an applescript run on shutdown or logout?  I know about  but I would rather have something free.  All my script does is mute the volume for the next startup.
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.