javascript

Can anyone recommend a good Hashtable implementation in Javascript?

I've found jCache and some other home-grown methods using associative arrays. If you've had experience with jCache, were there any limitations? ...

I need my html table's body to scroll and its head to stay put

I am writing a page where I need an html table to maintain a set size. I need the headers at the top of the table to stay there at all times but I also need the body of the table to scroll no matter how many rows are added to the table. Think a mini version of excel. This seems like a simple task but almost every solution I have found on...

What's the (JavaScript) Regular Expression I should use to ensure a string is a valid file name?

I'm still learning RegEx at the moment, but for the time being could someone help me out with this? I have a few special requirements for formatting the string: No directories. JUST the file name. File name needs to be all lowercase. Whitespaces need to be replaced with underscores. Shouldn't be hard, but I'm pressed for time and I...

How do I add a <table> using Element with Prototype in IE6?

Using Prototype 1.6's "new Element(...)" I am trying to create a <table> element with both a <thead> and <tbody> but nothing happens in IE6. var tableProto = new Element('table').update('<thead><tr><th>Situation Task</th><th>Action</th><th>Result</th></tr></thead><tbody><tr><td>a</td><td>b</td><td>c</td></tr></tbody>'); I'm then tryin...

In JavaScript, is there a source for time with a consistent resolution in milliseconds?

The Date object in javascript performs differently machine to machine and browser to browser in respect to the function's resolution in milliseconds. I've found most machines have a resolution of about 16 ms on IE, where Chrome or Firefox may have a resolution as good as 1ms. Is there another function available to javascript in general...

What is the best method to convert to an Integer in JavaScript?

There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice? Here are a few methods that I know of: var a = 2.5; window.parseInt(a); // 2 Math.floor(a); // 2 a | 0; // ...

"Son of Suckerfish" CSS Menu - sub menus not closing in IE7

Despite my most convincing cries to the contrary, I was recently forced to implement a horizontal drop-down navigation system, so I opted for the friendliest one I could find - Son of Suckerfish. I tested in various browsers on my machine and all appeared to be fine. However, some (but not all!) IE7 users are experiencing an issue wher...

jQuery - running a function on a new image

I'm a jQuery novice, so the answer to this may be quite simple: I have an image, and I would like to do several things with it. When a user clicks on a 'Zoom' icon, I'm running the 'imagetool' plugin (http://code.google.com/p/jquery-imagetool/) to load a larger version of the image. The plugin creates a new div around the image and allo...

How can I get jQuery to perform a synchronous, rather than asynchronous, AJAX request?

Hello. I have a javascript widget witch provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created. I've added an AJAX call into this function using jQuery: beforecreate: function(node,targetNode,type,to) { jQuery.get('http://example.com/catalog/create/'...

setting Radio Button enabled/disabled via CSS

Is there a way to make a Radio Button enabled/disabled (not checked/unchecked) via CSS? I've need to toggle some radio buttons on the client so that the values can be read on the server, but setting the 'enabled' property to 'false' then changing this on the client via javascript seems to prevent me from posting back any changes to the...

How do you create an HTML table with adjustable columns?

I want to know how to create a table where you can adjust the column widths. I have not figured out how to do this. If you know the secret sauce to this technique please let me know. ...

Javascript Post Request like a Form Submit

I'm trying to direct a browser to a different page. If I wanted a GET request, I might say document.location.href = 'http://example.com/q=a'; But the resource I'm trying to access won't respond properly unless I use a POST request. If this were not dynamically generated, I might use the HTML <form action="http://example.com/" method=...

How does "this" keyword work within a JavaScript object literal?

I just came across an interesting situation in Javascript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the this pointer is being used. From the behavior of the program, I have deduced that the this pointer is referring to the class on which the method was invoked, and ...

Is there any good Markdown Javascript library or control?

I want to build a site where the user can enter text and format it in Markdown. The reason I'd like a Javascript solution is because I want to display a live preview, just like on StackOverflow. My site is not targeted at developers, however, so an editor control would be ideal. I gather that on StackOverflow, the WMD editor is being u...

How to listen to elements method calls in Javascript

Hello, I would like to listen to method calls. For example, when an element is appended by anything to the document, I would like to be passed that element to act on it, like: //somewhere aParent.appendChild(aChild); //when the former, a function I defined as listener is called with the aChild as argument Does anybody know how to d...

Where can I find a Perl module for converting a Perl data structure into a JavaScript one?

e.g. (Mason code): 16 % # convert our @cti data structure into a javascript one 17 var cti = [ 18 % foreach my $cti_category (@cti) { 19 { 20 label: "<% $cti_category->{'label'} %>", 21 value: "<% $cti_category->{'value'} %>", 22 children: [ 23...

Javascript: Trigger action on function exit

Is there a way to listen for a javascript function to exit? A trigger that could be setup when a function has completed? I am attempting to use a user interface obfuscation technique (BlockUI) while an AJAX object is retrieving data from the DB, but the function doesn't necessarily execute last, even if you put it at the end of the func...

Href for Javascript links: "#" or "javascript:void(0)"?

When building a link that has the sole purpose to run javascript, is it better to: <a href="#" onclick="myJsFunc();">Link</a> Or <a href="javascript:void(0)" onclick="myJsFunc();">Link</a> ...

VBScript: Using a variable within a DOM element

Hello all, I'm looking to use a VBScript variable within a reference to a DOM element for a web-app I'm building. Here's a brief exerpt of the affected area of code: dim num num = CInt(document.myform.i.value) dim x x = 0 dim orders(num) For x = 0 To num orders(x) = document.getElementById("order" & x).value objFile.writeLine(o...

How can I get Gmail-like file uploads for my web app?

I want to add gmail-like file upload functionality for one of my projects. Can anybody help me with this? My application is built in vb.net. I would appreciate any kind of help or guidance. Thanks Mithil Deshmukh ...