I have two different  functions in javascript. Function A) is a function, which shows a countdown on the page. Function B) , the other function is completely indepentent from function A).  But, when I start an alert() or confirm() in function B), the countdown in function A) pauses. So every background script is pausing.  Is there a way to disable the pause without changing the alert() or confirm() to jquery? This script is only running on one specific machine, so I also could change some parameters in the browser.  thanks in advance
123225
I'm looking for something like alert(), but that doesn't "pause" the script.  I want to display an alert and allow the next command, a form submit(), to continue. So the page will be changing after the alert is displayed, but it won't wait till the user has clicked OK.  Is there something like this or is it just one of those impossible things?
1554
I need to warn users about unsaved changes before they leave a page (a pretty common problem). window.onbeforeunload = handler  This works but it raises a default dialog with an irritating standard message that wraps my own text. I need to either completely replace the standard message, so my text is clear, or (even better) replace the entire dialog with a modal dialog using jQuery. So far I have failed and I haven't found anyone else who seems to have an answer. Is it even possible? Javascript in my page: &lt;script type=&quot;text/javascript&quot;&gt;        window.onbeforeunload = closeIt; &lt;/script&gt;  The closeIt() function: function closeIt() {   if (changes == &quot;true&quot; || files == &quot;true&quot;)   {       return &quot;Here you can append a custom message to the default dialog.&quot;;   } }  Using jQuery and jqModal I have tried this kind of thing (using a custom confirm dialog): $(window).beforeunload(function () {     confirm('new message: ' + this.href + ' !', this.href);     return false; });  which also doesn't work - I cannot seem to bind to the beforeunload event.
41585
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused.   And now that we're here, how do they differ from a regular function?
17026
I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created.   I've added an Ajax call into this function using jQuery:  beforecreate: function (node, targetNode, type, to) {   jQuery.get('http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),    function (result) {     if (result.isOk == false)          alert(result.message);   }); }   But I want to prevent my widget from creating the item, so I should return false in the mother-function, not in the callback. Is there a way to perform a synchronous AJAX request using jQuery or any other in-browser API?
22444
Need help in adding another function using the below script. I would like to have a timestamp "start" and "end" on two different columns, whenever the other two separate columns are edited. Based on the below script, I could only have one time stamp, from one column which is the column 2 and time stamp on column 10.  function onEdit()  {  var s = SpreadsheetApp.getActiveSheet();  if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet    var x = s.getActiveCell();    if( x.getColumn() == 2 ) { //checks the column      var nextCell = x.offset(0, +8);      if( nextCell.getValue() === '' ) //is empty?        var time = new Date();      time = Utilities.formatDate(time, "GMT", "hh:mm");        nextCell.setValue(time);    };  }; }
42411
How to check whether a JavaScript variable defined in cross-browser way?  I ran into this problem when writing some JavaScript utilizing FireBug logging. I wrote some code like below:  function profileRun(f) {     // f: functions to be profiled     console.profile(f.constructor);     f();     console.profileEnd(f.constructor); }   It works fine in FireFox/FireBug, but it reports error in IE8 RC1. So, I'd like to do some checking whether console variable exists in the execution environment.  Below code works fine in FireFox, but not in IE8 RC1.   function profileRun(f) {     if (console != undefined) {         console.profile(f.constructor);     }      f();      if (console != undefined) {         console.profileEnd(f.constructor);     } }   However, if I do it this way. It works in IE8 RC1. Why?   function profileRun(f) {     if (window.console != undefined) {         console.profile(f.constructor);     }      f();      if (window.console != undefined) {         console.profileEnd(f.constructor);     } }   Is there any cross-browser way to check it?
71120
I'm wondering if it's possible to sandbox JavaScript running in the browser to prevent access to features that are normally available to JavaScript code running in an HTML page. For example, let's say I want to provide a JavaScript API for end users to let them define event handlers to be run when &quot;interesting events&quot; happen, but I don't want those users to access the properties and functions of the window object. Am I able to do this? In the simplest case, let's say I want to prevent users calling alert. A couple of approaches I can think of are:  Redefine window.alert globally. I don't think this would be a valid approach because other code running in the page (i.e., stuff not authored by users in their event handlers) might want to use alert. Send the event handler code to the server to process. I'm not sure that sending the code to the server to process is the right approach, because the event handlers need to run in the context of the page.  Perhaps a solution where the server processes the user defined function and then generates a callback to be executed on the client would work? Even if that approach works, are there better ways to solve this problem?
5844
I have an input type="image". This acts like the cell notes in Microsoft Excel. If someone enters a number into the text box that this input-image is paired with, I setup an event handler for the input-image. Then when the user clicks the image, they get a little popup to add some notes to the data.  My problem is that when a user enters a zero into the text box, I need to disable the input-image's event handler. I have tried the following, but to no avail.  $('#myimage').click(function { return false; });
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.
647
I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.  The previous developer used two ways of declaring functions and I can't work out if there is a reason behind it or not.  The two ways are:  var functionOne = function() {     // Some code };     function functionTwo() {     // Some code }   What are the reasons for using these two different methods and what are the pros and cons of each? Is there anything that can be done with one method that can't be done with the other?
12141
I'm using an NSTimer to do some rendering in an OpenGL based iPhone app.  I have a modal dialog box that pops up and requests user input.  While the user is providing input I'd like to "pause" i.e. something like this:  [myNSTimer pause];   I'm using this syntax because I've been doing things like:  [myNSTimer invalidate];   when I want it to stop.  How can I programmatically pause the NSTimer?
72992
Let's say that I create a Sub (not a function) whose mission in life is to take the active cell (i.e. Selection) and set an adjacent cell to some value.  This works fine.  When you try to convert that Sub to a Function and try to evaluate it from from spreadsheet (i.e. setting it's formula to "=MyFunction()")  Excel will bark at the fact that you are trying to affect the value of the non-active cell, and simply force the function to return #VALUE without touching the adjacent cell.  Is it possible to turn off this protective behavior?  If not, what's a good way to get around it?  I am looking for something a competent developer could accomplish over a 1-2 week period, if possible.  Regards, Alan.  Note: I am using 2002, so I would favor a solution that would work for that version.  Having that said, if future versions make this significantly easier, I'd like to know about it too.
69971
Is there a keyboard key combination that I can use to pause a program running in the terminal? In case it matters, I don't intend to run anything else inside that terminal while the program is paused. I just want to pause the program execution, and resume it later. How can I do this?
123777
What is the difference between the three functions and when to use them??
19928
How can I exit the JavaScript script much like PHP's exit or die? I know it's not the best programming practice but I need to.
49395
In jQuery when you do this:  $(function() {    alert("DOM is loaded, but images not necessarily all loaded"); });   It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obviously what we want if we're initializing any DOM stuff such as showing or hiding elements or attaching events.  Let's say though that I want some animation and I don't want it running until all the images are loaded. Is there an official way in jQuery to do this?  The best way I have is to use &lt;body onload="finished()"&gt;, but I don't really want to do that unless I have to.  Note: There is a  in Internet Explorer which actually does wait for all images to load before executing code inside $function() { }. So if you're using that platform you'll get the behavior I'm looking for instead of the correct behavior described above.
52702
As far as I can tell, these two pieces of javascript behave the same way:  Option A:  function myTimeoutFunction() {     doStuff();     setTimeout(myTimeoutFunction, 1000); }  myTimeoutFunction();   Option B:  function myTimeoutFunction() {     doStuff(); }  myTimeoutFunction(); setInterval(myTimeoutFunction, 1000);   Is there any difference between using  and ?