javascript

If an onfocus event handler is added with attachEvent, how can I access it?

Background: I'm writing a script (in VBA, if that matters) to input data into a web-based system. Some of the system's validation is only run when a field is focused, so I've been calling .Focus on the fields in VBA to force it to run. But that steals the systemwide focus; rather annoying if I am doing anything else while the job is run...

How do you synchronize server-side and client-side code?

Something I've been learning (and teaching) in Software Engineering is that code duplication is the root of all evil. On the other hand, I find it quite hard to explain how this concept should be applied to the development of web apps. Allow me to clarify... Input & data validation can be an important part of a web app. Sometimes this ...

jquery keyup delay?

i have a search field where the user type in a search string and it searches. right now it searches for every keyup. so if he types Windows it will make a search with ajax for every key he press. W, Wi, Win, Wind, Windo, Windows. I want to have a delay instead, so it just search when he stops typing for 0.2s. There is no option for th...

IE8 - JavaScript dropdown onchange calling "role()" cause an error.

I am actually debugging an application for IE8 (after IE6, IE7 now IE8). I went received a bug in one of my interface when we were doing an action on a dropdown and I wondered why it wasn't happening before. I finally found out that a drop down (or a select) calling a method named "role()" directly wasn't supported. Does anyone know wh...

What mode do people use when using Emacs to edit web pages that contain CSS, javascript, and HTML?

typically the code is something like: <html> <head> <style type="text/css"> body { font-size:12pt; font-family: Arial;} .... </style> <script type="text/javascript" src="jquery.1.3.2js"></script> <script type="text/javascript"> <!-- $(document).ready(function(){ ... }); ...

get value in jquery

i have one function which return value in this format li#2.ui-widget-content li#6.ui-widget-content li#12.ui-widget-content li#1.ui-widget-content each time i run function i get random value in the above format. i want to get value after li# in jquery Thanks ...

Why would I want to use server-side JavaScript?

I'm confused, I regularly read talk of server-side JS, why would I want to use that? It seems like it would execute way slower than pretty much any other language, it also lacks many conventions that more sophisticated languages have. Is it possible to hand entire objects from the client to the server, manipulate them and return them ba...

Accessing Javascript Array without using [] Brackets

I'm trying to write some javascript in an environment where square brackets are used for macro replacement, so they can't be used as normal in the script. If I create an array as an object with new Array() I can use push() and pop() to access the elements, but for native arrays I can't figure out a way to get to the elements without usi...

How to get mouseup to fire once mousemove complete (javascript, jquery)

It seems that mouseup events are only fired when they are not in conjunction with a mousemove. In other words, push down on the left mouse button and let go, and mouseup is fired. But if you drag across the image and then let go, no mouseup is fired. Here is an example that shows this behavior: <script src="http://ajax.googleapis.com...

Regex to compare strings with Umlaut and non-Umlaut variations

Can anyone help me with a javascript regular expression that I can use to compare strings that are the same, taking into acccount their non-Umlaut-ed versions. for example, in German the word Grüße can also be written Gruesse. These two strings are to be considered identical. The mappings (ignoring casings for the moment) are: ä = ae ...

jquery - javascript variable not holding value

I'm using this code to submit a form to a php script: var valid = 'true'; $(document).ready(function(){ $("#contact").submit(function(){ $.post("process.php", $("#contact").serialize(), function(data){ if(data.email_check == 'invalid'){ valid = 'false'; //<---not set! $("#email1").addClass('...

Overlay thumbnail with remove image button?

Hi All i need to create a remove button that appear over my thumbs when a user hover that image with his mouse a link appear like remove from favorites ? anyone know how to achieve this ? an example of what i want is youtube quick list button u find over the videos thumbs .. http://i50.tinypic.com/fxdu2b.jpg Please help me if you kn...

Unterminated string constant error

We just dicovered a bug in our app that returns this error. When going to a certain page in our ASP.NET 2.0 app. When I press "Yes" to debug, the source of the page is displayed, but the line that is referenced has NO Java script on it. I am trying to figure what maybe causing the issue and how to debug it. This is IE only application. T...

JS timezone conversion

In Javascript, I have a timestamp which I'm handling like so: var origUnixTimestamp = (date * 1000); Along with this timestamp I have a UTC offset (-5, although this is variable). I'm looking to convert origUnixTimestamp to the users UTC offset, using Date's getTimezoneOffset() method. I'm just wondering how I take into account the or...

How to get old Value with onchange() event in text box

I have a text Box and a Value poplulated in it when page loads. Now If user chanegs any thing in text box, then I want to get the Changed Value(New Value) and Old Value but when I do ELEMENT.value then its giving only changed Value any Suggestions to get old value? below is my code <head> <script type="text/javascript"> fun...

Mechanize Ignore Javascript when Required by Page

Hello, I understand a few people have asked about JS support in Mechanize. My question might be a little bit different, and/or posed differently. I am looking to ignore the Javascript check and log in to a page that requires Javascript. The web site itself does not really need JS, but the developers felt they needed to require it for th...

Firefox AddEventListener issue

I have a web application that consists of two websites - one running on port 8080 (java) and other running on port 80 (IIS). The java web pages call into IIS web pages, which occassionally call back into java web pages to get additional information. The javascript that handles the communication/ exchange of data works in IE but not in Fi...

Reading web.config from JavaScript

IS there any way that I can read config values in web.config with javascript ? Why would I want to do that ? I have a timer in my website which would pop up a modal dialog with a count down timer (count down for 2 minutes) if the user is inactive for 20 minutes. If the user does not respond, it logs him out. If he does, it pings to the ...

Offset height using Prototype

I get different values from Prototype's cumulativeOffset function in Internet Explorer 8 and Firefox 3.5 within a complex layout with several elements having paddings and margins. This seems to be a known bug: Discussion Does anybody know a prototype based or prototype compatible method of reliably determining the offset height of a s...

What's a good regular expression to capture the root domain of a given url?

Ideally, I'd like to capture foo.com from something like http://foo.com/bar?param=value or https://www.foo.com Thanks. Edit: Sorry for the vagueness. I'll be doing this in Javascript. 2nd Edit: I should post my terrible first attempt: https?://w?w?w?[.]?[^?/] ...