javascript

Firefox Exension vs. Greasemonkey Script?

I've been working on a Firefox extension extension, but it's been slow going (in part because I have no time to work on it). I've got a basic skeleton, verified that I can talk to an external JSON API, modify any webpage when loaded, and show a preferences box. These are all necessary HelloWorlds for the extension I am writing (maybe I d...

Another Javascript Undefined Null Question

So I have been through most of the questions here. Also quite a few articles good and bad. One thing I am looking for some additional clarification on is how undefined and un declared variables are treated. Take the code below. var a; if(a == null) // True - Due to Type Coercion if(a == 'null') // False if(a === null) // False ...

Javascript run-time analysis

Hello, I've written a Javascript file, using jQuery, that I would like to perform run-time tests on. I've never done this before and was just curious on how to go about it. One site I visited suggested this as a measurement: var start = (new Date).getTime(); /* Run a test. */ var diff = (new Date).getTime() - start; This makes sense...

Bonjour Discovery in Javascript? Maybe?

So its a longshot, I'll start with that. Is it/could it be possible to discover bonjour advertised HTTP services in javascript alone? Why would this be useful? Imagine a local service looking after some data (eg your current lat/long), the data is exposed via a webservice and advertised by Bonjour Zeroconf. A (remote) website might wan...

check if jquery has been loaded, then load it if false

Does anyone know how to check if jquery has been loaded (with javascript) then load it if it hasnt been loaded. something like if(!jQuery) { //load jquery file } ...

multiple document.ready()'s performance metrics

I have several javascript files that during run-time get combined and minified. This is for an enterprise application with 10+ developers. There are document.ready functions all over the place causing 5+ second javascript load. I'd like more help in figuring out where the bottlenecks are by slowly removing pieces of functionality. E.g. ...

hide text but not input inside a label jquery

i have a label and input outputted from the shopping cart we are using. i dont want to hack the core of the cart to change the way it outputs. so the code is thus with the input inside the label: <div id="FormField_29" class="FormField"> <label for="FormField_29_0"><input type="checkbox" id="FormField_29_0" name="FormField[2][29][0]...

non-jquery javascript cross-browser livesearch/autocomplete

Is there a good cross-browser livesearch (autocomplete) library available? I need something that handles these aspects well cross-browser: handles keypress interaction creates/displays a table and calls back a function when either the tab, enter and/or space keys have been pressed has hooks for external javascript to hide/destroy the t...

How do I pass the image object into the onclick function being assigned to it?

Sorry if that question is confusing, I'm self-learning javascript. I'm dynamically generating image thumbnails and I want to be able to enlarge the image when the user clicks on the thumbnails. My code to create the image tag and assign the onclick function looks like... var imageTag = "<img onclick=\"enlargeImage()\" class=\"thumb\" s...

Change content of jQuery carousel dynamically

I am trying to do something similar to this: http://www.amazon.com/Black-Friday-After-Thanksgiving-Sale/b/ref=nav_swm_thd?ie=UTF8&amp;node=384082011&amp;pf_rd_p=499992511&amp;pf_rd_s=nav-sitewide-msg&amp;pf_rd_t=4201&amp;pf_rd_i=navbar-4201&amp;pf_rd_m=ATVPDKIKX0DER&amp;pf_rd_r=0642T42GTS6J8H2JKMEF If the link does not work, go on Amazo...

Unfamiliar characters used in JavaScript encryption script

Here is an excerpt from a JS encryption script that I am studying. function permutationGenerator(nNumElements) { this.nNumElements = nNumElements; this.antranspositions = new Array; var k = 0; for (i = 0; i < nNumElements - 1; i++) for (j = i + 1; j < nNumElements; j++) this.antranspositions[ k++ ] = ( i << 8...

Javascript is telling me a node has 23 children, but it only has 11 and firebug agrees with me.

Im working on a HTML test page with a simple grid that has red or blue squares. If you click a red square it should be blue, if you click a blue square it should change to red. Sounds easy. I have it set up so there are rows with id's r + rownum. In my testfile i just have 2 rows: r1 and r2. Each row has the same number of children (rig...

how can I get yesterdays date in unix format in javascript?

Hello! I'm self-learning the REST concept and am playing with the Flickr API. One of the parameters that Flickr requires is the min_upload_date, which is formatted in the Unix date format and looks like this in the example... &min_upload_date=1199145600 I'd like to set the min_upload_date to the day before the current day, but I don...

Calling javascript from code behind

I have a c# asp.net 3.5 app I am trying to open a window from code behind after a certain event. I have this but its not working and there are no errors in firebug protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (openCredentialsWindow) { if (openCredentialsWindow_ClientI...

Check if a key is down?

Is there a way to detect if a key is currently down in JavaScript? I know about the "keydown" event, but that's not what I need. Some time AFTER the key is pressed, I want to be able to detect if it is still pressed down. P. S. The biggest issue seems to be that after some period of time the key begins to repeat, firing off keydown and...

How can you tell when a <div> is full of text?

Imagine a website with an element The site wants to run some JS which will fill the div with random text, when the div is full it should clear and start over. Yes I know that sounds weird but the question is, how can the JS know when the div is full, and would start to overflow? By 'full', I mean no more visible text can be put in the ...

How do I disable warnings from Aspx files (HTML,CSS)

All my aspx files give all kinds of annoying warnings like "The CSS Value is not defined" because I'm referencing CSS files from other projects relative to where they will be published in IIS. And other things I ignore like "Zoom is not a valid css property" even though I need it to fix crappy IE 6 rendering bugs. I tried adding Warnin...

Reload external javascript after asynchronous postback via UpdatePanel

I have an external javascript on my page, e.g. something like: <script src="http://foo.com/script.js" type="text/javascript"></script> and an UpdatePanel somewhere. The script writes some content, and does this from within an anonymous javascript function in the js file. I.e., there is something like this in the script: (function(){d...

Using Ajax.Updater to get a javascript file (prototypejs)

Here is my ajax request: new Ajax.Updater({ success: 'footer' }, '/dyn/actions/checkSystemMessage', { insertion: 'after', evalScripts: true }); Here is what's at /dyn/actions/checkSystemMessage: <script type="text/javascript"><!-- document.observe('dom:loaded', function() { buildSystemMsg = function(SystemMsg) { //behind ...

Array inside a Javascript Object?

I've tried looking to see if this is possible, but I can't find my answer. I'm trying to get the following to work: var defaults = { 'background-color': '#000', color: '#fff', weekdays: {['sun','mon','tue','wed','thu','fri','sat']} }; It just gives an error, and I've tried using ({...}) and [{...}] I'd like to be able to access th...