javascript

How to count the advertisement hits and stores it in database

We put our website advertisement in 2 other websites. We need to count the hits we are getting form those advertisement and like to store it in my database. Please give me an idea to do that. ...

Select All CheckBoxes in GridView ASP.NET using JQuery

I have checkBoxes in my Gridview templete columns called "Category A" and "Category B". I want Select-All functionality, i.e. when the user checks the Select-All check Box in category A column, all the checkboxes must get checked under that column. Same for Category B. I am trying with the code below. The problem with my code is, it sel...

Parsing a JSON feed from YQL using jQuery

I am using YQL's query.multi to grab multiple feeds so I can parse a single JSON feed with jQuery and reduce the number of connections I'm making. In order to parse a single feed, I need to be able to check the type of result (photo, item, entry, etc) so I can pull out items in specific ways. Because of the way the items are nested withi...

jquery, javascript and callback timing

var blah = Some.Thing(data, function(a,b) { // code here }); Some.Thing = function(data, callback) { if(...) { var a = Other.Thing(data, function() { // code here callback(); return; }); } callback(); }; My question is, will the part that says //code here fire only after everyth...

Javascript Anonymous Functions and Global Variables

I thought I would try and be clever and create a Wait function of my own (I realise there are other ways to do this). So I wrote: var interval_id; var countdowntimer = 0; function Wait(wait_interval) { countdowntimer = wait_interval; interval_id = setInterval(function() { --countdowntimer <=0 ? clearInterval(interval_id) : nu...

Millisecond to various GMT tomezones conversion

Hi, I have a time in millisecond i.e. 1274203800000, now i want to convert it into GMT + 10 in javascript. currently i am using following code to do that var milliseconds=1274203800000; var offset='+10'; var d = new Date(milliseconds); utc = d.getTime() + (d.getTimezoneOffset() * 60000); nd = new Date(utc + (3600000*offset)); var res...

Knowing the language used in a form

I'm working on a site with forms that require a certain language to be used. (Something like a dictionary). I want to know if there is a way in JavaScript/HTML to check the language. For example, if I need the input in Japanese and the user gives me an English word, it is detected as an error. ...

Javascript function, on web page close

Hello there, I have an problem that i can not solve. The problem is this way: When i close my page on some browser i want an message box to appear and to ask me if I really want to close the page or not. logically: click on x (close tab on web browser) and than the box appears with two buttons yes and now, if i click yes the page wi...

convert javascript comma separated string into an array

I have a comma separated string that I want to convert into an array so I can loop through it. Is there anything built-in to do this? ...

Problems crossing the boundary between protected greasemonkey execution space and the unsafeWindow land

Hi guys. Here is my problem: I've registered some callbacks into a Yahoo event driven webpage (betfair.com market views) and am trapping the betsPlaced events with a handler. So far so simple. Next stage is to get the event back into greasemonkey land, and while I know that from greasemoney space you can call unsafeWindow.stuff, ther...

Using argument (this) passed via element eventhandler

Hey guys, I want to use the argument I pass (this) in a JS function and treat it as an jQuery variable. Example: <script> function useMe(obj){ $(obj).val(); ... ... ... } </script> <select id="selectid" onChange="useMe(this)"> <option>......</option> </select> Is there a possibility to treat the passed argument as ...

Is there an easy way to do click-and-drag scrolling in text frames?

I have a div with overflow:auto and a scroll bar, and I'd like to be able to drag the contents to scroll. I don't need to be able to select text. Is there an easy way to do this? A jQuery plugin would be good, otherwise plain old JavaScript would be fine. It seems I haven't made myself clear enough. There's a div with a fixed height tha...

show/hide html table columns using css

I want to display a basic html table with controls to toggle showing/hiding of additional columns: <table id="mytable"> <tr> <th>Column 1</th> <th class="col1">1a</th> <th class="col1">1b</th> <th>Column 2</th> <th class="col2">2a</th> <th class="col2">2b</th> </tr> <tr> ...

JavaScript inner function scope chain?

In this example var a = 1; ( function(x) { function inner() { alert(a); alert(x); alert(y); } var y = 3; inner(); })(2); When does function inner get created? during execution time or parsing time of outer anonymous function? What is in the scope chain of function inner? What is the difference betw...

What JavaScript framework is the least evil?

I'm not a huge fan of the JavaScript frameworks that are out there today. I think a lot of the libraries could be written better, are chosen for a project because of favoritism rather than understanding the requirements of the problem at hand, and some JavaScript developers come to depend on them too much to the point where they are jQue...

Ruby equivalent to JavaScript’s encodeURIComponent that produces identical output?

Hi is there an equivalent ruby method to JavaScript encodeURIComponent method? i am using the URI.unescape(str) but it recognizes the "£" (after encodeURIComponent it becomes "%C2%A3") as a "?" sign. any solution's? thanks ...

jQuery .width() and .height() strange behaviour

Why in the following code .height() returns 95 rather than 100, while .width() returns 200 as expected ? I work with Firefox 3.6.3. HTML: <table><tr> <td id="my"></td> </tr></table> <div id="log"></div> CSS: #my { border: 5px solid red; } JS: $("#my").width(200).height(100); $("#log").append("Width = " + $("#my").width() + ...

What javascript min tool does jquery use?

I have a great deal of javascript that needs to be min'd before being served to the end user. Currently, I'm using JSMIN, but I'd like to switch to something a bit more powerful (such as something with local variable replacement). I'm currently looking at YUI min developed by yahoo, and it got me thinking about the min tool that jquery...

Ajax method within an added method in jQuery validator

Hi, I'm kind of stuck with this pretty simple (I'm sure) jQuery/Javascript issue. Here's the code : jQuery.validator.addMethod("emailExists", function(value, element, param) { var email = value || ''; var valid = 0; $.ajax({ type: "POST", url: param, data: "email=" + email, success: function(msg) { if (msg != '' ...

Javascript permission denied. Not cross domain?

I'm working on a web app that very rarely returns a Javacript permission denied error when attempting to access document elements. I'm well aware of cross-domain issues and I am actively pursuing them as a possible cause. My question is: are there other possible causes for a permission denied exception? Just want to make sure I'm look...