javascript

catching button clicks in javascript without server interaction

I've got a sign up form that requires the user to enter their email and password, both are in two separate text boxes. I want to provide a button that the user can click so that the password (which is masked) will appear in a popup when the user clicks the button. currently my JS code for this is as follows: function toggleShowPass...

Where can I download the jQuery API documentation?

Since I pound API docs pretty hard when I'm coding, I like to have them on my local disk. jQuery.com lists a lot of sources for browsing the API documentation online, but I haven't found anywhere I can download an HTML bundle as a TAR or ZIP file. Is such a bundle available? EDIT: I should have said that I want an HTML version. UPDATE:...

Is there any way to repopulate an Html Select's Options without firing the Change event (using jQuery)?

I have multiple selects: <select id="one"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <select id="two"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> What I want is to select "one" from the first select,...

Safely turning a JSON string into an object

Given a string of JSON data, how can you safely turn that string into a JavaScript object? Obviously you can do this unsafely with something like... var obj = eval("(" + json + ')'); ...but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval. ...

How do I know if Javascript has been turned off inside browser?

I assume that you can't use a javascript code snippet to validate if the browser user has turned off javascript. So what can i use instead? Can someone offer a code sample? I'm looking to wrap an if/then statement around it. I often code in CFML, if that helps. ...

How do I return an array of strings from an ActiveX object to JScript

I need to call into a Win32 API to get a series of strings, and I would like to return an array of those strings to JScript. This is for script that runs on local machine for administration scripts, not for the web browser. My IDL file for the COM object has the interface that I am calling into as: HRESULT GetArrayOfStrings([out, retv...

A problem with the jquery dialog when using the themeroller css

Hello, The demos for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found that I can't control any input element contained in the dialog (i.e, can't type into a text field, can't check checkb...

Javascript collection of DOM objects - why can't I reverse items order with Array.reverse()?

What would be the problem with reversing the array of DOM objects got from a command like: var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); When i call the reverse() method, the script stops executing with the error 'imagesArr.reverse is not a function'...

How do you automatically set the focus to a textbox when a web page loads?

OK, this has to be insanely easy but I honestly don't know how to do it. How do you automatically set the focus to a textbox when a web page loads? Is there an HTML tag to do it or does it have to be done via javascript? ...

How do I get js2-mode to use spaces instead of tabs in Emacs?

I am using js2-mode to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2. ...

What is the most efficient way to sort an Html Select's Options by value, while preserving the currently selected item?

I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's text, value, and selected properties, but I don't think that javascript's built in Array.sort() would work correctly. ...

How do I use the JavaScript Console in Google Chrome?

I have a Font Detect code that does not work in Google Chrome, and I thought I would find out what is going on. But I still can't figure out how I can add breakpoints or do watch etc. I am looking for something like FireBug. I assume I would need to install a third party debugger? ...

What is the best approach for (client-side) disabling of a submit button?

Details: Only disable after user clicks the submit button, but before the posting back to the server ASP.NET Webforms (.NET 1.1) Prefer jQuery (if any library at all) Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much...

Validate email address in Javascript?

What's the best way to validate an email address in Javascript? Though this solution may be simple, I'm sure this is one of those useful things that people will be Googling for and deserves its own entry on the site ...

Good ways to improve jQuery selector performance?

I'm looking for any way that I can improve the selector performance of a jQuery call. Specifically things like this: Is $("div.myclass") faster than $(".myclass") I would think it might be, but I don't know if jQuery is smart enough to limit the search by tag name first, etc. Anyone have any ideas for how to formulate a jQuery select...

How to determine if user selected a file for file upload?

If I have a <input id="uploadFile" type="file" /> tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user. In FF, I just do: var selected = document.getElementById("uploadBox").files.length > 0; But that doesn't work in IE. ...

Referencing Embedded resources from other resources in c#

In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using ClientScriptManager.GetWebResourceUrl(). However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resources as well. Is there a...

Using JQuery, what is the best way to set onclick event listeners for radio buttons?

For the following HTML: <form name="myForm"> <label>One<input name="area" type="radio" value="S" /></label> <label>Two<input name="area" type="radio" value="R" /></label> <label>Three<input name="area" type="radio" value="O" /></label> <label>Four<input name="area" type="radio" value="U" /></label> </form> Changing from the...

Javascript and CSS parsing performance

I am trying to improve the performance of a web application. I have metrics that I can use to optimise the time taken to return the main HTML page, but I'm concerned about the external CSS and Javascript files that are included from these HTML pages. These are served statically, with HTTP Expires headers, but are shared between all the...

Javascript tree views that support multiple item drag/drop

We are currently using the ExtJS tree view in an application - a requirement has arisen requiring a user to select multiple nodes (which the tree view supports currently through a pluggable selection model) - but you can not then drag the multiple selections to another part of the tree. Does anyone know of an ajax control (commercial or...