javascript

Readonly Input field will not fire OnKeyPress in IE6

I am implementing a special behaviour for the Enter key. The problem is my ASP.net library generates a readonly field; and when users tab into this field (tabbing into it is meaningful; so I want that behaviour) and press Enter to submit the form, it won't submit because it's a readonly field. I wrote a workaround that hooks up your ord...

How to construct a web file browser?

Goal: simple browser app, for navigating files on a web server, in a tree view. Background: Building a web site as a learning experience, w/ Apache, mod_python, Python code. (No mod_wsgi yet.) What tools should I learn to write the browser tree? I see JavaScript, Ajax, neither of which I know. Learn them? Grab a JS example from t...

Process form data using jQuery

I'm currently using Prototype, but I'd like to rewrite this function to jQuery: function post(div,url,formId) { new Ajax.Updater(div, url, { asynchronous:true, parameters:Form.serialize(formId) }); } HTML example that goes with it: <form method="post" action="" id="foo" onsubmit="post('result','getdata.php','foo');retu...

Jquery Multiselect - Trigger event manually?

I'm using the jquery multiselect control from: http://abeautifulsite.net/notebook/62 I need to manually check one of the options via javascript on a specific event. Whenever I try to change the checked attribute, or trigger a click, call the click function explicitely etc., I the checkbox gets checked but the CSS is never changed and t...

prototype.js - Element.insert( Element) ignored under IE 6?

I am using IE 6 (corporate mandated version) on XP, as well as (primarily) Firefox 3. In these, I am making a DHTML table using the prototype.js library version 1.6.0.3. I have event handler javascript code to add a row to the table, which works fine under Firefox, but is completely ignored under Internet Explorer. I can walk through ...

Browser waits for ajax call to complete even after abort has been called (jQuery)

I have some (potentially) long-running ajax calls that I would like to abort if the user navigates to another page. The following jQuery code calls abort on all pending XMLHttpRequest objects upon navigating away from the page: $.ajaxSetup({ beforeSend: function(xhr) { $(window).bind('beforeunload', function() { xhr.abort...

How do you handle HTML element IDs and Javascript references when adding line items using Javascript?

First off, I read all of the suggested questions that sounded halfway relevant and didn't find anything that addressed my issue. Second, if this is already addressed somewhere, I didn't search well enough for it. Finally, on to the problem. :D I have a page that has a 'line item' on it. A 'line item', for our purposes, is simply a b...

How to prevent Javascript injection attacks within user-generated HTML

I am saving user-submitted HTML (in a database). I must prevent Javascript injection attacks. The most pernicious I have seen is the script in a style="expression(...)". In addition to this, a fair amount of valid user content will include special characters and XML constructs, so I'd like to avoid a white-list approach if possible. (L...

Detect IE8, IE7, Safari, FireFox with jQuery 1.3+?

I need to change a value based on each browser since they all render differently. if (navigator.appName == 'Netscape'){ top = 17; } This was working but unfortunately both Firefox and Safari show up as "Netscape" How would I use jQuery 1.3.2 to detect all these? I couldn't find any info under jquery.support now that jquery.browser ...

File data from input element

In Firefox 3 it is possible to access the contents of a <input type="file"> element as in the following. Assume a form with the following element: <input type="file" id="myinput"> Now the data of the file selected can be accessed with: // Get the file's data as a data: URL document.getElementById('myinput').files[0].getAsDataURL() ...

Virtual Earth VEShapeLayer Will Not Render

The goal: Allow user to turn on and off different layers of data; and to dynamically pull the data for the current extent from a database on map move event. This works fine and good if you hard code your VEShapeLayers as done here. My list of layers is coming from a database, I have everything working the way I want except that when I ...

JCSompress - dealing with special characters in JS files?

I'm in the initial stages of investigating JSCompress for MSBUILD : http://msbuildtasks.tigris.org/ For my initial testing I have a few JS files over which I am running this task, some of the files include already minified JS files (JQuery Library etc..) and some files contain Special characters. When the task runs everytime it encount...

Simple regex problem: Replacing words with '?'s

Alright, here's my current test function: function make_void( str ) { var str_arr = str.split( /[\W]+/ ); var voidstr; var newstr = ""; for ( var i = 0; i < str_arr.length; i++ ) { voidstr = str_arr[i]; // if ( Math.random() <= 0.9 ) // { voidstr = voidstr.replace( /\w/gi, "?" ); // } newstr += voidstr + " "; } do...

DragAndDrop in selenium

Hi all, While using DragAndDrop function on a splitter control what I see is first it gets stuck most of the times. Also when I give the offset as +70 it moves to the position which is 70 units away from the start of the screen. What I understand is that it should move 70 units away from where it is now. Any idea why this is not workin...

How to figure out what site to add to cookie whitelist?

There is a banking site that I cannot login to unless I allow all cookies to be accepted. I am using Firefox 3.0 and I have set it to not accept cookies except from the defined list (Tools - Options - Privacy - Cookies - Exceptions). I've added all the sites captured by Live HTTP Headers to the whitelist, but the login is still disabled....

Joining multiple event handlers in Javascript.

How to join multiple event handlers in Javascript as in the following scenario : onClick="doSomething();" onKeyUp="doSomething();" onLoad="doSomething();" ...

[jQuery] slideDown and slideUp errors

Hello, I am new to jQuery and already I'm seeing problems with the built in slideDown()/slideUp() animations. I'm using a flexible width element, and when I use the function, the element does not return to it's full width. I am thinking this has something to do with the way jQuery finds the width of the element. I am experiencing the e...

Allowing user to edit / add / move items in an image

Here's what I'm looking to do: I have an image, let's say of a room. This is going to be a static image. I want the user to be able to do the following: 1. add a set of images, like a chair, desk, etc. 2. move items which are already on the image. 3. edit text attached to an image. I need this image to be stored on the server, as wel...

What might cause an XMLHttpRequest to never change state in Firefox?

I'm working on some old AJAX code, written in the dark dark days before jQuery. Strangely, it has been working fine for years, until today when it suddenly stopped firing its callback. Here's the basic code: var xml = new XMLHttpRequest(); // only needs to support Firefox xml.open("GET", myRequestURL, true); xml.onreadystatechange = fu...

HTML form with two submit buttons and two "target" attributes

Hi I have one html <form> The form has only one action="" However I wish to have 2 different target="" attributes depending on which button you click to submit the form. This is probably some fancy javascript, but I haven't an idea where to begin. Any ideas how I could create two buttons, each submit the same form, but each button gi...