Skip to content
Advertisement

Tag: javascript

Loop through a ‘Hashmap’ in JavaScript

I’m using this method to make artificial ‘hashmaps’ in javascript. All I am aiming for is key|value pairs, the actual run time is not important. The method below works fine. Are there any other ways to loop through this? I run into a problem where this outputs a bunch of undefined keys after the first key, when the array only

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

Advertisement