javascript

What is the best JavaScript code to create an img element

I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have: var oImg=document.createElement("img"); oImg.setAttribute('src', 'ht...

Google Maps API - GMarker.openInfoWindowHtml() stopped working

I have a Google Map that suddenly stopped working for no apparent reason (I hadn't touched the code for months, but the wrapper code from our CMS may have changed without Corporate telling me). http://www.democratandchronicle.com/section/builder (sorry about the nasty HTML outside the map, most of that comes from our corporate parent.....

Is there an offline version of JSLint for Windows?

I would like to check my JavaScript files without going to JSLint web site. Is there a desktop version of this tool for Windows? ...

.load in jQuery not loading cfcharts in IE6

I am trying to dynamically load the contents of a div tag with a .cfm page that contains a cfchart in png format. When the user clicks on a link, I am using the load function to put the .cfm page into the div. $("#bank").bind("click", function(){ $("#chartx").load("bank.cfm"); }); I can get this to come up perfectly in Firefox, bu...

What is the best way to serialize SVG from the client DOM?

I am working on interactive SVG/AJAX interfaces where elements are created and repositioned on-the-fly by users. I'd like to support the ability for users to export their current view to a PNG image and/or an SVG document. I'd really like the SVG document to be as simple as possible (without a lot of nested transforms). Is there any fram...

How to automate JavaScript files compression with YUI Compressor?

YUI Compressor does not accept wildcard parameters, so I cannot run it like this: C:>java -jar yuicompressor.jar *.js But I have over 500 files and would rather not have to create a batch file like this: C:>java -jar yuicompressor.jar file1.js -o deploy\file1.js C:>java -jar yuicompressor.jar file2.js -o deploy\file2.js ... C:>java...

Best way to implement .lastChild using Prototype or jQuery

Currently we are using prototype and jQuery as our js frameworks. Right now, jQuery is set to $j() to prevent conflicts from prototype. In the past, we've used a lot of prototype's Element.down(), Element.next(), and Element.previous() to traverse the DOM. However, I need a simple way to retrieve the last child element. I know i can loo...

Select Box onClick - Rails

Hi, I have a Rails application that in the erb code, I use a select box. What I would like to do is reload the page passing the sort parameter. My controller already handles it, but I don't know how to reload the page with the selected value from my select box. Here is my code: <% @options = {:latest => 'lastest' , :alphabetical => 'alp...

JavaScript - extract folder names

Hello. I'm fairly new to JavaScript. Given a local machine's folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called. Thank you very much in advance. ...

Common sources of unterminated string literal

I am trying to debug a javascript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." I checked the line and the lines around it and everything seems fine-parentheses, braces, and quotes are balanc...

A form that spits out the input

I can't for the life of me find a form that DOESNT email the results that you submit. I'm looking to find a form that I can have users enter simple data that i can then spit back out at them in different arrangements. If they submit First and Last, I'll spit out, amongst other things, [email protected]. I'm willing to scrounge the co...

Reacting to click on ListItems in CheckboxList

I would like to apply some logic to a page containing a CheckBoxList control when the user checks or unchecks individual checkbox items. Say, for instance to dynamically show or hide a related control. I came up with a way using ASP.Net 2.0 callback mechanism (AJAX) with a combination of client-side Javascript and server-side logic in t...

Programatic Accent Reduction in JavaScript (aka text normalization or unaccenting)

I need to compare 2 strings as equal such as these: Lubeck == Lübeck In JavaScript. Why? Well, I have an auto-completion field that's going out to a Java service using Lucene, where place names are stored naturally (as Lübeck), but also indexed as normalized text, import sun.text.Normalizer; oDoc.setNameLC = Normalizer.normalize...

Javascript percentage validation

I am after a regular expression that validates a percentage from 0 100 and allows two decimal places. Does anyone know how to do this or know of good web site that has example of common regular expressions used for client side validation in javascript? @Tom - Thanks for the questions. Ideally there would be no leading 0's or other tra...

Prevent redirection of Xmlhttprequest

Is it possible to prevent the browser from following redirects when sending XMLHttpRequest-s (i.e. to get the redirect status code back and handle it myself)? ...

Could a website force the browser to go into fullscreen mode?

I want to run a psychological study for which participants have to look at large images. The experiment is done on the web and therefore in a browser window. Is it possible to tell the browser to go into fullscreen, for example on button press? I know there is the possibility to open a fixed-size popup window. Do you think this would b...

What are some great JavaScript sites?

I have often found it hard to find good JavaScript help on the net. What are some websites that you have found useful for JavaScript. Here are a couple of mine: irt.org specifically the JavaScript FAQ now Stack Overflow Let me know if there are other questions on SO similar to this, because I couldn't find them. ...

Get GridView selected row DataKey in Javascript

I have GridView which I can select a row. I then have a button above the grid called Edit which the user can click to popup a window and edit the selected row. So the button will have Javascript code behind it along the lines of function editRecord() { var gridView = document.getElementById("<%= GridView.ClientID %>"); var id = // s...

Converting XML-RPC to JSON in JavaScript

Can anyone recommend a lightweight JavaScript XML-RPC library? After researching this a while ago, I couldn't find anything I was comfortable with, so I kinda ended up writing my own. However, maybe that was stupid, as there must be something suitable out there!? My own pseudo-library is mainly missing a way to turn an XML-RPC response...

Dynamically Set the Height of Two floated DIVS

The coding is done using VS2008 There are two divs in my page namely "dvLeftContent" and "dvRightContent". I cannot statically set the height of the pages since "dvRightContent" have variable heights on various pages (Master Pages are used here) Is there a client side function(javascript or jquery) that takes the height of the right div ...