I am drawing lines using Canvas (HTML 5), since lines/shapes are not stored as objects in Canvas, I cannot attach unique events to it (eg onmouseclick) I wish to attach a onmouseover event to a line, is it possible by getting to know if the mouse if over a particular line (using its 2 X and 2 Y co-ordinates) …
Convert hyphens to camel case (camelCase)
With regex (i assume) or some other method, how can i convert things like: marker-image or my-example-setting to markerImage or myExampleSetting. I was thinking about just splitting by – then convert the index of that hypen +1 to uppercase. But it seems pretty dirty and was hoping for some help with reg…
“google is not defined” when using Google Maps V3 in Firefox remotely
Here’s my conundrum: I have a page that uses Google Maps V3 and jQuery. It all worked well locally in FF5, Chrome and Safari. Once I uploaded to a web site, I get a “google is not defined” error on the first line that I try to use a google object It only occurs in FF and only occurs remotely
Removing all script tags from html with JS Regular Expression
I want to strip script tags out of this HTML at Pastebin: http://pastebin.com/mdxygM0a I tried using the below regular expression: But it does not remove all of the script tags in the HTML. It only removes in-line scripts. I’m looking for some regex that can remove all of the script tags (in-line and mu…
how to disable buttons based on a condition in jsp?
how can I disable a button by checking a condition in my jsp? If true,then the button is enabled,if false,then the button is disabled. The condition would be checking the value of a variable. I know how to disable a button using javascript, but to use it along with the condition in jsp is what I’m not a…
Is it possible to alter a CSS stylesheet using JavaScript? (NOT the style of an object, but the stylesheet itself)
Is it possible to alter a CSS stylesheet using JavaScript? I am NOT talking about: I AM talking about altering: besides doing something dirty (which we haven’t tried yet btw), like creating a new object in the head, innerHTML a style tag in there, etc. Although this, even if it did work, would pose a few issu…
Is it possible to create an HTML canvas without a DOM element?
I’d like to have an HTML canvas context that I can paint to and read off-screen (in this example, writing text and reading the shape that is created, but it’s a general question). I may also want to use a canvas as an off-screen frame-buffer. I suppose I could create a hidden DOM element but IR…
Set default value of Javascript object attributes
Is there a way to set the default attribute of a Javascript object such that: Answer Since I asked the question several years ago things have progressed nicely. Proxies are part of ES6. The following example works in Chrome, Firefox, Safari and Edge: Read more in Mozilla’s documentation on Proxies.
javascript innerHTML adding instead of replacing
quick question, i know we can change the content of a <div id=”whatEverId”>hello one<div> by using: now, is there a way I can ADD stuff to the div instead of replacing it??? so i can get <div id=”whatEverId”>hello one hello two<div> (using something similar of c…
How to serialize an Object into a list of URL query parameters?
Without knowing the keys of a JavaScript Object, how can I turn something like… …into… …? Answer Example: http://jsfiddle.net/WFPen/