Skip to content
Advertisement

Get Line co-ordinates in Javascript

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) in

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 regex that could make the code cleaner. No jQuery…

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 multi-line). It would be highly appreciated if

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 able to figure

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.

Advertisement