I am creating a slideshow of animations using animated GIFs. I’m crossfading from one animation to the next. The problem is: the only way I have discovered to ensure that the GIF starts animating from the first frame is to reload it each time it’s shown. The GIFs are 200KB or so each, which is way…
Tag: javascript
Best way to document anonymous objects and functions with jsdoc
Edit: This is technically a 2 part question. I’ve chosen the best answer that covers the question in general and linked to the answer that handles the specific question. What is the best way to document anonymous objects and functions with jsdoc? Neither the PageRequest object or the callback exist in c…
Why do I get wrong, doubled input value on keyup when typing fast?
When one is typing slowly “a” & “b” the above code will result in “a”, “b” in the console log. But the problem is when somebody does it quickly. The result then is “ab”, “ab”. It’s easier to repeat this situation with letters wh…
Convert integer into its character equivalent, where 0 => a, 1 => b, etc
I want to convert an integer into its character equivalent based on the alphabet. For example: etc. I could build an array and just look it up when I need it but I’m wondering if there’s a built in function to do this for me. All the examples I’ve found via Google are working with ASCII values and not a
Unexpected behaviour on bookmarklet submit or related database action
[updated below] I have a bit of a problem deploying a site on apache with mod_wsgi with some javascript bookmarklet functionality. The problem is that the bookmarklet (which is a browser menu button) submits to a page like http://stemhub.org/submit/http://the-users-link.com/here which then returns a form to s…
Remove empty tags using RegEx
I want to delete empty tags such as <label></label>, <font> </font> so that: will be cleaned as: I have this RegEx in javascript, but it deletes the the empty tags but it also delete this: “<i>italic</i></p>” What I am missing? Answer You have “not s…
Disable same origin policy in Chrome
Is there any way to disable the Same-origin policy on Google’s Chrome browser? Answer Close chrome (or chromium) and restart with the –disable-web-security argument. I just tested this and verified that I can access the contents of an iframe with src=”http://google.com” embedded in a p…
Get the Size of a CSS Background Image Using JavaScript?
Is it possible to use JavaScript to get the actual size (width and height in pixels) of a CSS referenced background image? Answer Yes, and I’d do it like this… Some notes… We need to remove the url() part that JavaScript returns to get the proper image source. We need to split on , in case t…
Calling a method from an event handler
I have this code I am working on but every time I call init method I keep getting an error: this.addElement is not a function Is it because I can’t call methods from event handlers? Answer You should read this book, JavaScript: the Good Parts and visit the Crockenator’s web site here, crockford.co…
I am trying to make a simple toggle button in javascript
I am trying to make a simple toggle button in javascript. However, the button will only turn “OFF” and will not turn back “ON” I am running:HP Netbook : Ubuntu Linux 10.04 : Firefox for Ubuntu 1.0. Answer Both of your if statements are getting executed one after each other, as you chan…