javascript

How do I communicate between threads in JavaScript?

I created an XPCOM object in C++ for a FireFox extension. I'm using a worker thread to listen for an event and when it happens, I need to do stuff on the main thread. Obviously, I can't just sit and wait in JavaScript on the main thread because you need to be able to use the browser (my event happens very rarely). I tried doing this in t...

Javascript Namespacing, what am I doing wrong?

I'm taking an existing JS library I wrote up some time ago, and trying to organize it under a common namespace...Here is an example of the technique I am trying to use: var NameSpace = new function () { var privateMember = []; function privateMethod() {}; return { PublicMethod1 : function(arg, arg2) { ...

JavaScript Library Performance Comparisons - any resources out there?

I'm putting together a presentation to my company on the reasons I'm adopting jQuery as the preferred JavaScript / AJAX library. While most of the work is done, a comparison between different libraries would be of great use - especially against the Microsoft ASP.Net Ajax framework. Now please note I'm not after a theological debate on ...

Javascript semaphore / test-and-set / lock?

Is there such a thing as an atomic test-and-set, semaphore, or lock in Javascript? I have javascript invoking async background processes via a custom protocol (the background process literally runs in a separate process, unrelated to the browser). I believe I'm running into a race condition; the background process returns between my tes...

Adding additional js files breaks jQuery IntelliSense

I have been using jQuery IntelliSense in VS2008 and it has been great. Recently I added a reference to jQuery UI and since then, the jQuery IntelliSense has went away. I found that once you reference another .js file in your document, the IntelliSense goes away. Any way to avoid this? ...

Javascript Date Localization

I'm working with an ASP.NET app with localization and globalization. I'm having some difficulty understanding how to get the Date() function in javascript to work properly given the user's environment. My user base is split between Mexico (spanish) and the US (english). Since the Mexico date format is dd/mm/yyyy and the english format...

IE focus on form element in ajax response

i have tried setTimeout, eval, try/catch, callback functions etc and nothing works reliably. this has been driving me nuts for ages! here is a test case ...

Cross-site ajax call to a WCF Service

Is it possible to do a cross-site call, in Javascript, to a WCF service? I don't mind if it's a POST or a GET. But I've heard that these days, browsers don't allow cross-site calls with either POST or GET. How can I circumvent this and still call a WCF Service? ...

Submitting a Javascript object to PHP

Dear fellow developers, A newbie question from me, please. I have a large data set that I prefer to be submitted as an object instead of an array; e.g. foo = bar = baz = {}; $.ajax({ url: "index", type: "post", data: { foo: foo, bar: bar, baz: baz }, dataType: "json" }); Upon submit, Firebug tells me that I have submi...

Put javascript in one .js file or break it out into multiple .js files?

My web application uses jQuery and some jQuery plugins (e.g. validation, autocomplete). I was wondering if I should stick them into one .js file so that it could be cached more easily, or break them out into separate files and only include the ones I need for a given page. I should also mention that my concern is not only the time it t...

Javascript in FF Extension versus Bookmarklet

Hi, I wanted to click this button programatically: http://rk.100webspace.net/1.cgi Typing either into the address bar works: javascript:window.content.document.forms[0].elements['Insert'].click(); javascript:document.body.childNodes[3]['Insert'].click(); But neither works when I do it from a extension: function CountP(event)...

A good Javascript API reference documentation related to browsers and DOM

I am looking for a good API documentation for Javascript especially related to browsers and DOM. I am not looking for any kind of Javascript tutorial, but simply a documentation for all standard Javascript classes and for classes used in web browsers. Something similar to Java's Javadoc ( http://java.sun.com/j2se/1.4.2/docs/api/ ) ...

Combine and compress CastleProject MonoRails' formhelper.js and behaviour.js?

Anyone who works with CastleProject MonoRails MVC who knows if I can combine and/or compress formhelper and behaviour js files together into something like monorails.js? I want to get the amount of webrequests as low as possible.. ...

Javascript Replace innerHTML throwing Unknown Runtime Error

function DeleteData(ID) { var ctrlId=ID.id; var divcontents=document.getElementById(ctrlId).innerHTML; var tabid=ctrlId.replace(/div/,'tab'); var tabcontents=document.getElementById(tabid).innerHTML; alert(document.getElementById(tabid).innerHTML); document.getElementById(tabid).innerHTML="<TBody><tr><td></td></tr><tr><td></td></t...

COM object and javascripts

Hi, I tried to consume 3rd. party COM object from JavaScript. from some reason, it crashes my internet explorer with no apparent reason when the object is beig disposed. The COM object works perfectly when using it from other environments (like vb and C#) any suggestions? can it be IE security setting that cause the problem? does anyn...

Why use document.write?

Hi, I was wondering why ad's still use the document.write approach to inserting the add into the page <script language="javascript" type="text/javascript"> document.write("<script type='text/javascript' src='http://addomain/someadd.js'&gt;&lt;\/sc" + "ript>"); </script> Why is it that I can't just put <script type='text/javasc...

Modify MP3 properties using javascript

Hi friends, Is it possible to modify the properties of the mp3 files. The properties such as artist, album, title and so on. I need to alter those fields. Only in javascript. Please help me. ...

google.setOnLoadCallback with jQuery $(document).ready(), is it OK to mix?

I'm using Google Ajax API and they suggest I use google.setOnLoadCallback() to do various things related to their API but I'm using also jQuery's $(document).ready() to do other JS things, not related to Google API. Is it safe to mix these two approaches in one document? I did not notice any problems yet but I suppose it's a matter of s...

Why won't this form validate?

The "onsubmit" statement is not called: <form action="index.php" method="post" onsubmit="return validateSearchKeyword()"> <input class="text_search" id="text_search" name="text_search" type="text" value="search" onfocus="if (this.value=='search') this.value = ''" onBlur="if (this.value=='') this.value = 'search'" /> </form> ...

YUI 3 Chaining

YUI 3 allows you to write Y.all(".foo").removeClass("bar"); However it does not allow writing Y.all(".foo").removeClass("bar").set("innerHTML", "baz"); It seems all the "operational" methods always terminate the call chain. This means YUI 3 only provides half the power of chaining that jQuery provides. Does anyone know why this is, an...