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…
Populating JavaScript Array from JSP List
Ok so perhaps someone can help me with a problem I’m trying to solve. Essentially I have a JSP page which gets a list of Country objects (from the method referenceData() from a Spring Portlet SimpleFormController, not entirely relevant but just mentioning in case it is). Each Country object has a Set of…
How to change the playing speed of videos in HTML5?
How to change the video play speed in HTML5? I’ve checked video tag’s attributes in w3school but couldn’t approach that. Answer According to this site, this is supported in the playbackRate and defaultPlaybackRate attributes, accessible via the DOM. Example: The above works on Chrome 43+, Fi…