javascript

How to catch the end filename only from a path with javascript ?

If I have a variable 'path' which contains a full path with directories and all, to the filename, how can I strip everything except the filename? ex: Convert dir/picture/images/help/filename.jpg into filename.jpg Thanks ...

Get the selected option from a list

hello, I'm trying to get the selected option via jQuery everytime I change it, and eventually the value attribute, buy I always have problems with js!! HTML <select> <option value="us">United States</option> <option value="gb">United Kingdom</option> <option value="de" selected="selected">Germany</option> <option value="fr">France<...

How can I catch everything after the underscore in a filepath with JavaScript?

How can I catch everything after the last underscore in a filename? ex: 24235235adasd_4.jpg into 4.jpg Thanks again! ...

Cursor location in text-input fields

There is a lot of information on how to place the cursor exactly where you want it to be in a textarea. None of it seems to work for an <input type="text"> field. Basically, when the page loads, I have an input field with text in it, and it's focused. The problem is that the cursor is at the end of the pre-written text. I need it to be ...

MooTools: Set focus on click

I've got an ASP.NET control that contains a checkbox. I want the focus to remain on this checkbox when it's clicked. Here's what I'm using: <script type="text/javascript"> window.addEvent("domready", function() { var acceptCheckId = $("<%= this.accept.ClientID %>").getElement("input"); acceptCheckId.addEvent("click...

how to get size of DIV at 100% zoom?

If a web page is zoomed out/in in any modern browser, then how I can find size of a DIV element at 100% zoom? EDIT:: I asked another similar question here, which was unanswered. ...

When NOT to use AJAX in web application development?

I'm building a web application with the Zend Framework. I have wanted to include some AJAX type forms and modal boxes, but I also want my application to be as accessible as possible. I want my application to be enhanced by AJAX, but also fully functional without AJAX. So as a general guideline...when should I not use AJAX? I mean, shoul...

onchange attribute won't call function

I have an HTML document (here), which creates an iframe-based media player for a collection of songs within albums (I just used letters to define these albums and songs in the mymusic array, for simplicity). Focusing on the top 3 iframes, the way I have set out the user interaction is to generate the HTML for forms of available albums a...

What does the following javascript code do?

javascript:void(document.cookie="PREF=ID=20b6e4c2f44943bb:U=4bf292d46faad806:TM=1249677602:LM=1257919388:S=odm0Ys-53ZueXfZG;path=/; domain=.google.com"); ...

custom choices in javascript confirm dialog.

How to write a confirm dialog in javascript with custom choices? Instead of just "Ok" and "Cancel", I would like to have for example "This" "That" and "Other". ...

Why does this Prototype code work like this?

This is my html: (note: I didn't use a background image on the a just for simplicity to show someone how this could work) <div class="foo"> <ul> <li><a href="#" class="bar"><img src="bar.gif" /></a></li> <li><a href="#" class="baz"><img src="baz.gif" /></a></li> </ul> </div> And my JavaScript: <script type="t...

JavaScript: Set border radius

How can I set the -moz-border-radius with pure JavaScript (no jQuery, no plugins etc)? document.getElementById('id') ...

Firefox doesn't execute one dynamically loaded <script> element until another is loaded

I'm implementing Comet using the script tag long polling technique, based on this page. Following on from my previous question, I've got it all working, except for one annoyance, which only happens in Firefox. On the initial page load my Comet client JavaScript sends two requests to the Comet server (in the form of dynamically generated...

best way to gather statistics from web widget

I have a web widget, which is basically a JS file that people can reference to in their website and it does something cool lets say. currently I'm gathering statistics by doing an AJAX request to some dummy image file on my server, its like this: http://www.myserver.com/image.png?views=120&amp;openings=80&amp;close=65 I monitor these...

Using Firebug From Within a Firefox Extension's code

Does anyone know how I can use firebug from an overlay.js script in a Firefox extension? I'm on Snow Leopard (just in case it makes a difference). I'm developing an extension but it's taking me forever because I have no visibility into my javascript objects. Thanks! ...

Firebug debugging JavaScript

Is there a way I can attach the debugger to an event? I have a checkbox input element in my DOM and when it's clicked, I'd like the debugger to break so I can step through what's happening. I've added onclick="debugger; ...", but Firebug doesn't break. ...

Loading script tags via AJAX

I have a div tag which is filled with script via an ajax call, but the script does not execute. Is there a way to cause the script to execute? ...

In JavaScript, why is [ ] preferred over new Array(); ?

I remember reading somewhere (I think it was in one of Crockford's papers) that using an array literal [] is better than using the new Array(); notation. But I can't really remember any advantages of one over the other. Can anyone please explain to me on why the former is preferred over the latter? [Update] Here is a reason on why []...

Can firebug tell me the javascript name of an object?

I've been adding quite a bit of javascript to my pages lately, but have learned it all in classic seat-of-the-pants fashion. When I want my page to do something, I google and experiment until I get the result I want. I frequently have objects in my pages that I want to activate/deactivate, hide, show, etc., but - having missed the ri...

Pass a value from JSP to Javascript

I am working with google maps and I am trying to pass a value from my database (Access) to my javascript code. I have var centerPoint = new GLatLng( <% Double.parseDouble(myclass.getLatitude()); %> , <% Double.parseDouble(myclass.getLongitude()); %>); where myclass.getLatitude() returns a string representation of my latitude and I ...