Skip to content
Advertisement

Tag: html

Trying to unbind events on iPad2 with javascript

Bit of background, we are creating an html5 ‘app’ for the iPad, which has everything contained in a single page, and all the content is dynamic. I have a dynamically generated anchor, which then has a click event bound to it as so: This all works fine, however the problem is that once we navigate away from that page/section, and

Actual key assigned to JavaScript keyCode

I have setup an event listener: When the user presses 2 along with shift, how do I know if I should output (@) or (“)? Each users’ character mapping is different per locale. Answer Use the keypress event instead. It will reliably (barring a few edge cases) detect the character typed. There are a few browser oddities (such as some

html5, what is isContentEditable?

chrome supports the isContentEditable property (lists it in the “Inspect Element”), but reports false for INPUT, FORM – actually, everything. too me, for example, seems that INPUT, non-readonly, should be true. does anybody know what’s going on? Answer isContentEditable doesn’t have anything to do with forms and input boxes. It was designed to be a way to flag inline editable

Detecting keydown/up events during HTML5 native drag

I’ve an element that can be dragged using native HTML5. It has dragstart, drag, and dragend event listeners assigned to it. In addition, I also have keydown and keyup event listeners assigned to document.body element. When dragging the draggable element, ondrag event will fire as expected. When I press & release any key while not dragging anything, document.body keydown/up events

Replace too long strings with “…”

Lets say we have a <div style=”width:100px;”>This text is too long to fit</div> The text in the div is dynamic. And I’d like to force the text to fit in width and not break. So i need some kind of functionality to test if the text is going to fit, and if it is not, then i’d like to display

javascript – shuffle HTML list element order

I have a list: Using javascript how can I reorder the list items randomly? Answer This is based on Fisher–Yates shuffle, and exploits the fact that when you append a node, it’s moved from its old place. Performance is within 10% of shuffling a detached copy even on huge lists (100 000 elements). http://jsfiddle.net/qEM8B/

Disable button whenever a text field is empty dynamically

Here’s my code: This works but still not efficient since the user can delete the text inside the text box and click the button while he’s holding on DELETE key. Is there a more efficient way to achieve this using javascript? Answer Add a check when the button is clicked to see if there is any text. If there isn’t,

Open Gmail on mailto: action

How to force web-browser to navigate to Gmail and create (if logged in) new letter with filled in field ‘To’ on click on mailto:SomeMail@blabla.example? Answer There’s a Greasemonkey script. The compose URL is: https://mail.google.com/mail/?view=cm&fs=1&to=email@domain.example

javascript focus() not working on Firefox and IE?

I’m trying to appear a form and focus it, for some reason it only works on Chrome. How can I make it work across browsers? You can see it not working in here: http://jsfiddle.net/CCxrp/1/ What can I do to make it work? Thanks Answer You just need to swap the order of things: The divs have to be in the

Advertisement