Is it possible to chain setTimout functions to ensure they run after one another? Answer Three separate approaches listed here: Manually nest setTimeout() callbacks. Use a chainable timer object. Wrap setTimeout() in a promise and chain promises. Manually Nest setTimeout callbacks Of course. When the first one fires, just set the next one. Chainable Timer Object You can also make
Tag: javascript
In javascript how can I dynamically get a nested property of an object
If I want ‘foo’ vs ‘bee’ I can just do arr[variable] – that’s easy, and the function does that. But what if I want to get arr.bar.baz AKA arr[bar][baz]? What can I pass to the getter function that will let me do that, (and of course also let me get non-nested properties using the same function). I tried getter(‘bar.baz’) and
How to convert a bookmarklet into a Greasemonkey userscript?
Is there a easy way to do this. And is there anything that needs to be changed due to differences in how it is ran? Answer The easiest way to do this: Run the bookmarklet code through a URL decoder. so that javascript:alert%20(‘Hi%20Boss!’)%3B, for example, becomes: javascript:alert (‘Hi Boss!’); Strip the leading javascript: off. Result: alert (‘Hi Boss!’); Add
Mouse cursor disaappears on keypress event in Jquery
I am using arrow keys to move an object in my code. Everything works fine except that the mouse cursor disappears when I press any of the arrow keys. How can I make the cursor stay visible? I am using this code check for arrow keys pressed. Answer That’s browser behavior (maybe even OS behavior!), you probably won’t find a
JavaScript infinite up and down element scrolling?
I’m wondering if there is a simple way to make use of JavaScript (probably jQuery too?) in order to make the contents of a fixed-height div element scroll infinitely up and down (top, bottom, top, bottom, etc) when the page loads and without any user input or manipulation? Thanks ahead of time, any input is greatly appreciated as I am
Increase (youtube flash) video’s sound volume by means of JavaScript
Background story: many users (including me) browse the web from notebooks that are not constructed for sound performance. That means (besides other things) that the sound volume for most videos is too low, especially if the video itself is recorded at low volume. Therefore… I was wondering if there is any way of increasing the volume of such a video
Javascript showing in dollars
How would I display JavaScript output numbers in dollar format? I.E. $20.00 then $2,000.00 when the number gets larger. Ok so sample code. Answer Here’s the function that I use.. Basically the same as @Senad’s except it adds commas:
find element based on tabindex
Using jquery or javascript, how can I find the input element in the DOM that has a particular tabindex set to it, eg. I would want this element returned if I was searching for the element with tabindex = 7. Answer You can get it with the following jQuery
How do I hide javascript code in a webpage?
Is it possible to hide the Javascript code from the html of a webpage, when the source code is viewed through the browsers View Source feature? I know it is possible to obfuscate the code, but I would prefer it being hidden from the view source feature. Answer I’m not sure anyone else actually addressed your question directly which is
How can I put [] (square brackets) in RegExp javascript?
I’m trying this: And the replace doesn’t work, what am I doing wrong? UPDATE: I’m trying to remove any square brackets in the string, what’s weird is that if I do it works, but replace(/[]/g, ”); doesn’t. Answer It should be: You don’t need double backslashes () because it’s not a string but a regex statement, if you build the