Skip to content
Advertisement

getElementById in SVG document

I wrote a svg file like this: As in the comment line alert(document); alerts [object SVG document]. But: alerts null. I also tried to put svg in an html page, also in an xhtml page, tried more thing but no result for now. Any idea? Answer At the time you call var path=document.getElementById(‘path1’);, the path1 is not defined yet (it

What is the correct way of code comments in JavaScript

What is the correct way of code comments in Javascript – is the same syntax as in Java? And which tools actually would take advantage of these comments: I found new Resharper 6 (I write JS in VisualStudio 2010) offers the same comments as in C#, but only within the functions body, something like /// <param name=”overlayElement”></param> . The JS

Event handler returning undefined?

Let’s say I was attaching an event handler of jQuery click event to one of the function of my objects. But why does it return undefined on my properties? Answer You’re passing the function referenced by buttonView.onClick, but it’s association with buttonView is not retained. To retain the reference via this, you can use the jQuery.proxy()[docs] method. Now this in

Add commas or spaces to group every three digits

I have a function to add commas to numbers: Unfortunately, it doesn’t like decimals very well. Given the following usage examples, what is the best way to extend my function? Presumably the easiest way is to first split on the decimal point (if there is one). Where best to go from there? Answer Just split into two parts with ‘.’

How to completely hide the dockedItems toolbar

I’m able to hide items among the dockedItems of a TabPanel, but am wanting to temporarily hide the entire dock, because the toolbar itself still takes up space and the rest of the content does not fill the screen. So far, I do like so: Alternatively: But neither removes the dockedItems toolbar itself. I’ve even tried to give the dockedItems

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

Advertisement