javascript

Am I experiencing a memory leak, or just high memory usage in Firefox?

I'm loading some fairly big data sets in to firefox (500 k or so) and drawing tables with them. Firefox is using up to 400 megs of memory. How can I tell if Firefox is leaking memory, or is just using a lot of memory just because it can? Is there another browser which will use less memory if it doesn't need it? I get the feeling that fi...

Generate different JSON from XML

I am trying to generate some JSON from an XML file, but not a straightforward conversion. I wish to pick and choose bits and have a slightly different structure. I would rather not just concatenate a giant string together and was wondering if there were some decent libraries around to do this. Also, for testing I would like to be able ...

Get size of autosized control?

I have a situation where I have several listbox controls on the same asp.net page. They are currently autosized to keep data from truncating. However, I would like to be able to determine the width of the largest listbox and then alter the size of the other listboxes to be the same. The question is... How can I access the size of the...

I want to attach an event to a link dynamically.. But the onclick attach didnt work.

Guys, So I'm coding a Greasemonkey script for this website.. Anyway, my problem is I can't attach the onclick event into my newly created anchor. I don't know what's wrong, maybe because I'm in Greasemonkey thats why It didn't work as expected? function createButton() { var a = document.createElement('a'); var css = document.c...

What is the fastest way to get a dom element?

I'm performance-tuning my code, and am surprised to find that the bottleneck is not dom node insert, but selection. This is fast: var row = jquery(rowHTML).appendTo(oThis.parentTable); but the subsequent getting of an element inside "row" is slow: var checkbox = jquery(".checkbox input", row); I need to get the checkbox in every ...

I need to persist data on the client side (about 1M)

I need to persist my data on the client side, without it moving back and forth in each request (Kills the cookies option). I can't use special plugins/extensions. One thought I had was to generate a dynamic JS file with the needed data for the current session of the user and make sure it is cached. There is a small problem with that, as...

Is it considered a bad-practice to select distinct elements by catching their class/id in a string ?

Hi, I've been using Jquery for some time now and I have a question concerning bad/good practices. Here is the deal. Lets say we have this HTML: <span class="а_s_trigger" id="tekst1">text1</span> <span class="а_s_trigger" id="video1">video1</span> <div class="a_s_songvideo" id="showvideo1"> <obj...

How can I set a css ":hover" on a DOM created element in JavaScript?

I'm using the DOM to manage a JSON response from an AJAX function I'm running. The script I'm writing needs to be completely portable, so I am defining the styles for the created elements on the fly (meaning, no linking to an external CSS, and no providing CSS in the HTML doc itself, because I won't have control of the doc). I'd like to...

Set a function to run in 30 seconds and be able to cancel it?

I have an app thats really good but it wont load for some users. I have a lite version that always loads but not nearly as good so I want to set a javascript to wait 30 seconds and then switch from the main app to the lite app. But if the main app loads in the 30 seconds cancle the switch to it stays on the main app. Basically I want to...

Initializing JS components at the end of HTML or on "onload"?

For a while I had been running JavaScript component initialization by waiting for the "onload" event to fire and executing a main() of sorts. It seemed cleaner and you could be sure the the ID state of your DOM was in order. But after some time of putting that through its paces I found that the component's initialization was choked off...

Can we make IE7 treat a FILE TYPE=INPUT element as a single control?

When it comes to navigating through an HTML form by hitting the TAB key, Internet Explorer 7 treats an INPUT element with TYPE=FILE as two controls (see MSDN for details). The first time you hit TAB it focusses on the text field, and the second time it focuesses on the Browse button. This is invisible to JavaScript. The problem is I wan...

selectionStart-End with textareas

I'm having this annoying problem, I can't seem to get the starting and ending index of the focused text in a textarea, all I get is undefined like this: $('#myarea').selectionStart; // return undefined Did I do something wrong? ...

How to stop intense Javascript loop from freezing the browser

I'm using Javascript to parse an XML file with about 3,500 elements. I'm using a jQuery "each" function, but I could use any form of loop. The problem is that the browser freezes for a few seconds while the loop executes. What's the best way to stop freezing the browser without slowing the code down too much? $(xmlDoc).find("Object"...

How to communicate with index from AS2 file, being loaded by an AS3 file

We are loading an actionscript2 swf into an actionscript3 swf. as3 is embeded on the index page using the satay method. Is it possible to get a variable set on the index page from within the actionscript2 page, without using the as3 page as an intermediary (as this is not an option)? We've tried ExternalInterface, but how would we targ...

Send XML to server for testing

I need to test a program I wrote that receives XML as a text upload from a browser. I'm looking for a tool that will allow me to send the same content over and over instead of having to generate it new each time. I am looking for an Application that can send a text file to a server or a way to do this with JavaScript and HTML The sol...

How do i make a checkbox fire a function ?

I have a checkbox inside a <label> and i want that checkbox, when checked or unchecked, to trigger a function. I attached a onchange trigger to the checkbox but in IE6 the trigger only fires after the focus is turned away from the checkbox, while in FF3 and Chrome it fires right away. I removed the onchange trigger and attached a onclic...

Internet Explorer Javascript performance problem

JavaScript performance in Internet Explorer sucks. No news there. However there are some tips and tricks to speed it up. For example, there is this three part series. Still I find myself unable to squeeze decent performance out of it. Perhaps some of you have an idea what else to do so it was speedier? What I want to do is create a medi...

Design Decision - Javascript array or http handler

I'm building a Web Page that allows the user to pick a color and size. Once they have these selected I need to perform a lookup to see if inventory exists or not and update some UI elements based on this. I was thinking that putting all the single product data into multidimensional JavaScript array (there is only 10-50 records for any p...

Where can I find technical detail on JavaScript internal structures?

I would like to examine the structure of pieces of JavaScript, i.e. once an object has been interpreted, what is the structure of the memory space the interpreted parts occupy, e.g. it has an 'array' of members, probably a header record, etc. Pretty much like I can present a simple C function as assembly code, or vice versa. I have nev...

Toggle iframe scrolling in javascript?

How can I toggle an iframe's scrolling between on, off and auto in javascript? I tried changing the frame.scrolling attribute to "yes", "no" and "auto", but it doesn't have any effect. ...