javascript

How to temporarily disable a click handler in jQuery?

Say I have something like the following to trap the click even of a button: $("#button_id").click(function() { //disable click event //do something //re-enable click event } How do I temporarily disable the click event of the button until the end of the processing of the original click occurs? I basically have the div disappear ...

Web scraping sites that require javascript support

Possible Duplicate: Screen Scraping from a web page with a lot of Javascript I just want to do tasks such as form entry and web scraping, but on sites that require javascript support. And I also need to enter forms, scrape, and so on in the same session. Ideally, I'd like a way to control a web browser from the command line. And...

Is this a good way to do JS OOP?

I wanted to ask about the pros cons of my the following OOP style. I write my JS classes in the following manner. var MyClass = function() { // private vars var self = this, _foo = 1, _bar = "test"; // public vars this.cool = true; // private methods var initialize = function(a, b) { // ...

Jquery embedded quote in attribute

I have a custom attribute that is being filled from a database. This attribute can contain an embedded single quote like this, MYATT='Tony\'s Test' At some pont in my code I use jquery to copy this attribute to a field like this, $('#MY_DESC').val($(recdata).attr('MYATT')); MY_DESC is a text field in a dialog box. When I display...

How can I print an HTML document from C# or javascript without user confirmation?

I would like to send a print job to the printer without the user having to click "okay" on the print confirmation dialog window. Either C# code-behind or javascript would be fine, whichever works better. So... I know it it possible to print an HTML document, but is it possible to print without the user clicking okay? The reason I as...

Get control in javascript

I have a couple of textboxes that will contain dates only. If one textbox has a date and the user tries to submit without entering a date in the other date textbox they will be stopped before submit. The way I want to do this is with the following javascript function: function ClientValidate(sender, args) { // Get Both form field...

Search zip-codes fast with jQuery

I have a list of zip-codes that I need to search trough using jQuery. I have the zip-codes in a CSV file like this: 2407;ELVERUM 2425;TRYSIL 2427;TRYSIL 2446;ENGERDAL 2448;ENGERDAL The list is pretty big, over 4000 entries, zip-code and corresponding city. What the fastest way to search trough the list in the browser? JSON? If that...

Problem executing trackPageview with Google Analytics.

I'm trying to capture the clicks of certain download links and track them in Google Analytics. Here's my code var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { linkpath = links[i].pathname; if( linkpath.match(/\.(pdf|xls|ppt|doc|zip|txt)$/) || links[i].href.indexOf("mode=pdf") >=0 ){ /...

Delaying default events in Javascript

I would like to be able to delay the default action of an event until some other action has been taken. What it's for: I'm trying to build a reusable, unobtrusive way to confirm actions with a modal-type dialogue. The key wishlist item is that any javascript handlers are attached by a script, and not written directly inline. To make th...

jQuery/javascript: how to use 'contains' in an if statement?

I have HTML that looks like this: <div class="item-list"> <h3>Monday Sep 21</h3> <h3>Tuesday Sep 22</h3> <h3>Wednesday Sep 23</h3> If today's date is on the list, then that date should be red. If today is not on the list (hey, it's still August!), then the 21st should be red. I used this code to successfully turn Sept 21 red, but...

modifying select with DOM

hey, I've found some results for this on google but nothing satisfying so I was hoping someone here might know. It seems as though populating a select element using innerHTML does not work in IE I have set up a file that does nothing but that and it works with everything but IE, here's the code in case anyone cares: <html> <head></hea...

Potential problems setting window.location.hash

Hello, I have some javascript code which, at one point, sets window.location.hash to a specific string. This works fine in Firefox 3, but I want to know if I will run into problems with this later, i.e. is this a cross-browser solution (IE6 included)? Also, I am using ReallySimpleHistory. Will this mess up its internal state? Thanks ...

Sending an Ajax request before form submit

Is it possible to send an ajax request in onsubmit() of a form? I have been trying it and the results are flaky, mainly because probably if the browser happens to take longer sending my request than it takes sending the original form, my request is discarded as soon as the location of the loaded page change, so sometimes it never even hi...

Would javascript and similar scripting languages benefit from being strongly typed?

Just had my mind going today. I spent some time in IE debug mode, browsing the web as usual, and oh boy do I see many errors :) Most of these errors are because some value are of a different type than expected (at least as far as I interpret the error messages). What are the reasons JavaScript and similar scripting languages aren't stro...

Manipulate sIFR color with javascript

Is there a way affect the sifr hover color from a javascript event? I know you can set up sifr to have rollover states and that works fine, but what i'm trying to do is rollover an image and then have the sifr object's hover color show. Is this possible? I'd prefer not to rebuild the object if that's at all possible. I can't point you ...

jquery with dynamic template div rows building

ok i have a site which has many different templates with different htmls for each template. i want to know how can i render for each row for its section with paging dynamically with jquery? i dont want to store html in a var, because it changes with template and i want to make it easy for designer without needing to know jquery code. s...

How to convert PNG to GIF using javascript or other client-side tech?

I have a combination of client-side technologies creating PNG data in the browser. Is there a way to convert the PNG data to GIF for display in IE without sending the data to the server? Wondering if there is an existing JavaScript library that will parse the PNG data and output GIF, or even JPEG. I know that I can send the PNG data to a...

How to pass a JSON date value via ASP.NET MVC?

ASP.NET Json() formats and returns a date as {"d":"\/Date(1240718400000)\/"} which has to be dealt w/ on the client side which is problematic. What are your suggestions for approaches to sending date values back and forth? Thanks ...

Javascript multi-dimensional array issues

Here is a sample of the global.heights array: [[190, 76, 209, 57, 114, 171, 76, 513, 209, 171, 76, 152, 76, 76, 190, 114, 95, 76, 76, 95, 57, 133, 114], [152, 76, 133, 38, 95, 133, 76, 342, 190, 114, 57, 152, 76, 57, 133, 76, 76, 76, 57, 76, 57, 76, 76], [], []] What I need to do is make another array a part of the global array (simpl...

How to process unhandled part of XMLHttpRequest response without global variables?

How in JavaScript process unhandled yet part of XMLHttpRequest responseText only in onprogress/onreadystatechange handler, without using global variables for XMLHttpRequest, prevDataLength, nextreadPos and inProgress (for locking)? The problem is the following: I want to update web page based on currently received part of data obtained ...