javascript

What is setTimeout(function(){//dostuff}, 0); actually supposed to do?

Does this pattern: setTimeout(function(){ // do stuff }, 0); Actually return control to the UI from within a loop? When are you supposed to use it? Does it work equally well in all browsers? ...

ASP.NET - What is the correct approach to JSON based web services with jQuery?

What is the correct way to convert ASP.NET SOAP-based web services to JSON-based responses? ...And then call these from jQuery? What are "best practices" when integrating jQuery based AJAX and ASP.NET? Articles? Books? ...

Easiest way to sort DOM nodes?

If I have a list like this: <ul id="mylist"> <li id="list-item1">text 1</li> <li id="list-item2">text 2</li> <li id="list-item3">text 3</li> <li id="list-item4">text 4</li> </ul> What's the easiest way to re-arrange the DOM nodes to my preference? (This needs to happen automatically when the page loads, the list-order ...

Truncate a string nicely to fit within a given pixel width.

Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :) function fitStringToSize(str,len) { var shortStr = str; var f = document.createElement("span"); f.style.display = 'hidden'; f.style.padding = '0px'; ...

Differences on how XmlHttpRequest behaves with different browsers?

I am trying to see what are the gotchas in using XmlHttpWebRequest such that it works for Safari, Firefox and IE? ...

Yahoo Widget appending Image

I'm developing a Yahoo Widget. Using Javascript I'm attempting to append an image to the current viewing window. The image is not displaying. Interestingly enough i added a few alert statements to show my variables and check my work and realized that the image is actually popping up, and then dissapeearing. Does anyone know what I'm ...

Does JavaScript support verbatim strings?

In C# you can use verbatim strings like this: @"\\server\share\file.txt" Is there something similar in JavaScript? ...

Software that clicks e-mail links on page?

We are experiencing a strange bug on our website which we think is related to the software installed on user's computers. We have an e-mail link on a lot of pages, which is created using Javascript (so spambots won't get it). It seems the link is "clicked" automatically on some user's machines. Some users then discard the window by clic...

Site for mobile phone display

Hi friends, Here i need to create a site that should support all Internet accessible mobiles. May i use javascript, in Some forum they told that javascript doesn't work's in mobile phones. Suggest me clear, In mobile phone javascript work or not ? Thanks ...

Maximum number of cookies allowed

As far as Google searches tell me, the maximum allowed number of cookies depends very much on the browser, however I cannot find any recent data as to how much cookies are allowed on modern browsers. I need to store a somewhat large number of user preferences in cookies (for not-yet-registered users), so what would be the best way of do...

jQuery SimpleTree: Add a node programatically

I'm trying to add a new node to an jQuery SimpleTree, but all I seem to be able to get is "sTC.addNode is not a function"... var simpleTreeCollection = $('.simpleTree').simpleTree({ animate:true, drag:false, autoclose: false, afterClick:function(node){}, afterDblClick:function(node){}, beforeMove:function (destination, source, po...

Invoking WCF Service through Javascript

How can I access the WCF Service through JavaScript? My problem is, I have to access the operation contracts through the JavaScript (my website is not Ajax enabled). Previously for calling .asmx web services, I am using the following code snippet var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttp.open("POST", URL, false); xmlHt...

Is there any way to specify a suggested filename when using data: URI?

If for example you follow the link: data:application/octet-stream;base64,SGVsbG8= The browser will prompt you to download a file consisting of the data held as base64 in the link itself. Is there any way of suggesting a default file-name for the browser to use? If not, is there a javascript solution? I'm referring to HTML hyperlinks...

How would you prefer <script> elements handled?

Imagine the following. Html is parsed into a dom tree Dom Nodes become available programmatically Dom Nodes may-or-may-not be augmented programmatically Augmented nodes are reserialised to html. I have primarily a question on how one would want the "script" tag to behave. my $tree = someparser( $source ); .... print $somenode->...

What is the proper method for coding, then retrieving business rules static error (NOT exception messages) messages in an ASP.NET web application?

I've skinned this cat a few different ways over the last 6 years.. hardcoded strings, static classes with consts, and resource files. What approach do you use, and why? Bonus points for integrating with client-side error messages! ...

Javascript Scope Error

I'm currently working on a Google Maps project and am implementing a search function. In my search function I'm trying to have content on the side listing which search makers that were just added to the map correspond to each hall. However in assembling this string I run into a problem where my side_bar_html variable will not output if I...

EXtjs Grid Filters

Hello all, I am a new user of Extjs library, I created a grid successfully and it works just fine, now I want to use Ext.grid.GridFilters to add filtering to my grid, however I don't see this class in the Extjs source code files, where I can get the required files? ...

Suggestions for someone starting JavaScript programming?

I would like to know some really good tutorials, references or books about getting the basic foundations in JavaScript programming, and then learning really deep, but good foundation and language understanding is pretty basic I think. BUT please bear in mind that I am an experienced programmer with C++ and C# etc. so I wouldn't like the...

Show 'ghosted' example text in a field, and then clear it onblur

I'm trying to duplicate the effect used in the Firefox search box where, if the search field does not have focus ( the user has not clicked inside of it ), it just says Google in gray text. Then, when the user clicks in the box, the text is removed and they can fill in their search term. I want to use this to provide example field data ...

Accessing options in jQuery Datapicker

How can I access options that I set in a jQuery Datepicker? $("#testDatePicker").datepicker({ minDate: new Date(2005, 0, 26), showOn: 'button', buttonImage: 'js/themes/default/images/calendar.gif', buttonImageOnly: true }); var minDate = $("#testDatePicker").?????; ...