javascript

Probably obvious problem in JavaScript

Hi, I think this is just an obvious problem that I can't spot because I've been staring at code too long today. I have this callback as part of a JQuery POST: function(data){ if(data == 'yes') { $('div.done').show(); ...

Using Javascript RegExp to replace each match with an iterating number

I want to replace empty lines in my string with an iterating number e.g. replace String: "My first line My second line My third line" with " 1 My first line 2 My second line 3 My third line" I can match and replace these lines using var newstring = TestVar.replace (/(^|\n\n)/g, "\nhello\n"); However I'm struggling to ad...

How to Get Form Values in ASP.Net When Using Jquery.post

I am using the following scrip to post data into ASP.Net $.post(window.location, { name: "John", time: "2pm" }) In my page_load event , I am checking Request.Forms.AllKeys but the count is comming as zero. My form is <form name="aspnetForm" method="post" action="Default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspn...

Why do many javascript libraries begin with "(function () {"?

Why do many javascript libraries look like this: (function () { /* code goes here */ })(); It appears to define an unnamed function which is immediately called. Why go through this effort? ...

Simple javascript library for visualizing a graph/network in a circle?

I am looking for a javascript library which plots networks with the nodes arranged in a circle. There are some other good questions about javascript visualisation in general, but most of the things referenced seem to be quite heavyweight toolkits. I am looking for a simple API that lets me pass in an array of string pairs representing ...

Use JavaScripts methods on C#

I'm download web page and parse javascript code, which have in code hash and java decode function... please I want to call javascript decode method from C# program... In web page I've : window.decoded_hashes = {}; window.decodehash = function(hash) { window.dec_hash(hash); return window.decoded_hashes[hash]; window.dec_hash = func...

javascript jQuery binding

Hi everyone, I have problem with javascript that needs your help, any idea is highly appreciated. I am using jQuery to create an anchor and bind it with javascript function as follow: $(document).ready ( function() { var test = function(arg) { ...

Get the percentage of the page load using javascript?

Hi guys, I'm writing an iphone application and need to show a progress bar that shows the loading progress of a web page. I want to insert a JS function to this page and once I call it, it will give me the load progress (how much bytes have been loaded and the total size). Is this possible? Thanks ...

Zend Framework URI space encoding in PHP and Javascript

I've a Zend Framework URI like /controller/action/var1/value1/var2/value2 . Value2 has a space character in it. How should I encode it in PHP? When I use urlencode with value2, this converts space into '+' instead of '%20f'. Is that ok? This value2 is also added to a href location by javascript on client side. I'm using escape functio...

Positioning div above image dynamically via mouseover

I want to display div above image so that div's top is aligned with cursor. As cursor is moved, the div should be moved as well (right now just vertically). In IE (**pure javascript please**). <head runat="server"> <title></title> <style type="text/css"> #ToolTip{position:absolute; width: 200px;background-color:Lime; top:...

Customizing MWD for math equations

HI, I want to customize the WMD editor (or wmd-new) to convert TeX equations like $\frac{2}{3}$ to Google Charts API images () Is it possible to customize how the HTML is generated? ...

Aptana Alternatives

I am looking for javascript/css editors that are a good alternative to using aptana. The following are features I care about: 1) "learning-based" auto-complete within the file. Aptana does not necessarily know what all possible auto-complete values are, but it tries to guess based on references in the file. 2) auto-complete for css. A...

Pagination in JavaScript generated HTML page - not for the faint of heart

I am working with some legacy (circa 2003) javascript and html code and need some help paginating the html output that the following code generates. To see this in action - visit the site and click on the Capacity tab. Enter values in each of the fields and click on the Capacity Chart button. The bigger the numbers the larger the output...

possible to send javascript varargs?

Is it possible to send a variable number of arguments to a javascript function, from an array? my arr = ['a','b','c'] var func = function() { // debug alert(arguments.length); // for(arg in arguments) alert(arg); } func('a','b','c','d'); // prints 4 which is what I want, then 'a','b','c','d' func(arr); // pri...

How to add anchor tag to a URL from text input

I want to be able to take user inputted text in a comment field and check for URL type expression, and if it exists, add an anchor tag (to url) when the comment is displayed. I am using PHP on the server-side, and Javascript (with jQuery) on client, so should I wait to check for URL until right before it is displayed? Or add the anchor ...

How do I detect user's location from a webpage opened in the Android browser?

Visiting www.google.com on the Android browser (or even with an android spoofed user-agent), presents the option to "Share Location". When clicked, it uses the GPS/Cell phone towers to figure out the location. I tried the google.loader.clientLocation but that only works using the IP address. Is there a method to tap into the Android OS...

javascript apply on constructor, throwing "malformed formal parameter"

thanks to wonderful responses to this question I understand how to call javascript functions with varargs. now I'm looking to use apply with a constructor I found some interesting information on this post. but my code is throwing errors attempt 1: var mid_parser = new Parser.apply(null, mid_patterns); error: TypeError: Function.p...

Live AJAX content

My friend and I maintain a submission site with comments. We want to know if it is possible to have a constant AJAX connection. Basically, each submission has a comments section. My friend had an idea of having an alert appear on the page everytime a new comment came in. So, would it be possible to keep up a constant link between the AJA...

Moving a focus when the input text field reaches a max length

I do have a credit card number form. The number is divided into four parts just as on a real credit card. I want to add a JavaScript taste to the form where when a user types four letters in a field, the focus automatically goes to the next tag. But not in the last tag. By doing this, a user doesn't have to type "tab" key to move a focu...

Are JQuery and its peers helping or hurting JavaScript Knowledge?

I noticed most questions related to client-side script on SO are JQuery related and that got me thinking. I'm wondering what the ease of these libraries is doing to actual KNOWLEDGE of JavaScript and the DOM. So much is done for you that my fear is there is a growing number of web developers that actually know very little about JavaScr...