javascript

Are there any good Javascript code coverage tools?

Looking for a Javascript code coverage tool. Ideally, I'd be able to easily integrate with continuous builds. Looking for something that I can run cross-platform, but Windows only tools may be able to work. Does anybody have any good recommendations of tools to use or what tools to avoid? Note: I've already read through this question:...

Getting closest element by id

I have two elements: <input a> <input b onclick="..."> When b is clicked, I want to access a and manipulate some of its data. A does not have a globally unique name, so document.getElementsByName is out. Looking into the event object, I thought event.target.parentNode would have some function like getElementsByName, but this does not ...

Javascript - Applying class to an HTML tag given an attribute/value

I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have: <p height="30"> I want to apply a class="h30" to that paragraph so that I can style it in my style sheet. I can't find any information on getting the value of ...

How would you go about for switching a site from Prototype to jQuery

I have written a site in Prototype but want to switch to jQuery. Any ideas on how best make the switch? ...

How would you go about using the ASP.NET AJAX Control Toolkit in a project that doesn't use ASP.NET on the back end

Your backend could be PHP or Python but you want to use the controls from the ASP.NET toolkit is there a successful way to do this? ...

What is the best tool to benchmark my JavaScript?

I'm currently working on a JavaScript tool that, during the course of its execution, will ultimately traverse each node in the DOM. Because this has potential to be a very expensive task, I'd like to benchmark the performance of this script. What's the best, free tool for benchmarking a script such as this across the major browsers? Ide...

Dynamically inserting javascript into HTML that uses document.write

I am currently loading a lightbox style popup that loads it's HTML from an XHR call. This content is then displayed in a 'modal' popup using element.innerHTML = content This works like a charm. In another section of this website I use a Flickr 'badge' (http://www.elliotswan.com/2006/08/06/custom-flickr-badge-api-documentation/) to load ...

How do I insert a character at the caret with javascript?

Hi! I want to insert some special characters at the caret inside textboxes using javscript on a button. How can this be done? The script needs to find the active textbox and insert the character at the caret in that textbox. The script also needs to work in IE and Firefox. EDIT: It is also ok to insert the character "last" in the prev...

Is there a way to highlight the target of a bookmark? (www.site.com/page.htm#bookmark) ?

I want to link to bookmark on a page (mysite.com/mypage.htm#bookmark) AND visually highlight the item that was bookmarked (maybe having a red border). Naturally, there would be multiple items bookmarked. So that if someone clicked on #bookmark2 then that other area would be highlighted). I can see how to do that with .asp or .aspx b...

What's cleanest, shortest Javascript to submit a URL the user is at to another process via URL?

Like the Delicious submission bookmarklet, I'd like to have some standard Javascript I can use to submit any visited URL to a 3rd party site when that's possible by URL. Suggestions? For example, I've been using javascript:void(location.href="http://www.yacktrack.com/home?query="+encodeURI(location.href)) so far but wonder if there...

Help with aggressive JavaScript caching

I've run into a problem where I make changes to a few JavaScript files that are referenced in an HTML file, but the browser doesn't see the changes. It holds onto the copy cached in the browser, even though the web server has a newer version. Not until I force the browser to clear the cache do I see the changes. Is this a web-server co...

Prevent Use of the Back Button (in IE)

So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits them to be processed. In some instances they have to enter a comment on another page. What the users have figured out is that they don't have to enter a comment if t...

Best PHP Framework w/ AJAX Support?

Question I'm fairly familiar with many of the PHP frameworks out there, but I'm wondering which ones actually integrate AJAX functionality and which ones do it well? Ideally I'd love to find a framework that would allow me to avoid JavaScript alltogether (at least for typical/basic JavaScript functionality). Does such a thing exist? If...

How do I get an XML file as XML (and not a string) with Ajax in Prototype.js?

This code is from Prototype.js. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null. new Ajax.Request( /path/to/xml/file.xml, { method: "get", contentType: "application/xml", onSuccess: function( transport ) { alert( transport.responseXML ); } })...

How do I insert text into a textbox after popping up another window to request information?

I have an asp.net web page written in C#. Using some javascript I popup another .aspx page which has a few controls that are filled in and from which I create a small snippet of text. When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up" the dialog/popup page. I...

How do I maintain position of a DragPanelExtender across postbacks?

I already found this article: http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&amp;AspxAutoDetectCookieSupport=1 But I've got a different situation. I am embedding some hiddenFields inside of the master page and trying to store the position of the dragPanel in those. I am using javascript to store the position of the dragPanel and ...

JavaScript private methods

To make a JavaScript class with a public method I'd do something like: function Restaurant() { } Restaurant.prototype.buy_food = function() { // something here } Restaurant.prototype.use_restroom = function() { // something here } That way users of my class can: var restaurant = new Restaurant(); restaurant.buy_food(); restau...

Where is the console API for WebKit/Safari?

WebKit/Safari supports the console object, which is similar to what Firebug does. But what exactly is supported? There is a console documentation for Firebug, but where can I find the console documentation for Safari/WebKit? ...

How do I get the coordinates of a mouse click on a canvas element?

What's the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)? No legacy browser compatibility required, Safari, Opera and Firefox will do. Update: Thanks @Brian, the following is working (in Opera and FF3 at least): canvas.addEventListen...

Why can't I delete this cookie?!

Okay, here is the 411 - I have the following event handler in my Global.asax.cs file: private void Global_PostRequestHandlerExecute(object sender, EventArgs e) { if (/* logic that determines that this is an ajax call */) { // we want to set a cookie Response.Cookies.Add(new HttpCookie("MyCookie", "true")); } } Tha...