Skip to content
Advertisement

Tag: javascript

Why can I add named properties to an array as if it were an object?

The following two different code snippets seem equivalent to me: and because they both behave the same, and also typeof(myArray) == typeof(myObjects) (both yield ‘object’). Is there any difference between these variants? Answer Virtually everything in javascript is an object, so you can “abuse” an Array object by setting arbitrary properties on it. This should be considered harmful though. Arrays

Javascript Object Confusion

I’ve confused myself nicely here. My scenario is as follows: I can’t seem to call Dragger.RemoveAsset. I understand the why, my question is how do I call it? I’m trying to keep like-things separated (e.g. Dragger / EditBar) but I seem to get all sorts of mixed up in my event handlers. Any suggestions, good reading materials, etc. on this

Is there a way to select sibling nodes?

For some performance reasons, I am trying to find a way to select only sibling nodes of the selected node. For example, If I selected inner1 node, is there a way for me to access its siblings, inner2-4 nodes? Answer Well… sure… just access the parent and then the children. or… using jQuery: Edit: Cletus as always is inspiring. I

How to preload an ENTIRE web page

How can you preload an entire web page using JavaScript so that I can get that page cached in the users browser? I know how to preload images with JS but what I would like to do is preload the entire page. Use case: On my website, I have a google maps page with a lot of other content (images,

“Submit is not a function” error in JavaScript

Can anyone tell me what is going wrong with this code? I tried to submit a form with JavaScript, but an error “.submit is not a function” shown. See below for more details of the code: I also tried this: Both show me the same error 🙁 Answer submit is not a function means that you named your submit button

Ellipsis in the middle of a text (Mac style)

I need to implement ellipsis (“…”) in the middle of a text within a resizable element. Here is what it might look like. So, becomes When the element is stretched out to the width of the text, I want the ellipsis to disappear. How can this be done? Answer In the HTML, put the full value in a custom data-*

Get directory of a file name in Javascript

How to get the directory of a file? For example, I pass in a string I want a function that returns me I would prefer a built in function that does the job, instead of having manually split the string and exclude the last one. Edit: I am running on Windows Answer I don’t know if there is any built

How do I programmatically click on an element in JavaScript?

In IE, I can just call element.click() from JavaScript – how do I accomplish the same task in Firefox? Ideally I’d like to have some JavaScript that would work equally well cross-browser, but if necessary I’ll have different per-browser JavaScript for this. Answer The document.createEvent documentation says that “The createEvent method is deprecated. Use event constructors instead.” So you should

Detecting when Iframe content has loaded (Cross browser)

I’m trying to detect when an iframe and its content have loaded but not having much luck. My application takes some input in text fields in the parent window and updates the iframe to provide a ‘live preview’ I started with the following code (YUI) to detect when the iframe load event occurs. ‘preview-pane’ is the ID of my iframe

Advertisement