javascript

Javascript game / Server communication / Answer validation

I have a quiz-like javascript game and it is supposed to be fast-paced. The user needs to answer as many questions as he can in a short time. He is presented with a Yes/No question, the answer is sent to the server, validated there and a feedback (correct/incorrect) is shown back to him. I use Javascript and AJAX. The problem is the del...

Onblur, what is the next control which will gain focus?

I am firing some code onblur() of a textbox. But I want to do something different if the user clicked on the cancel button to cause that onblur(). Is there a way within the onblur() event handler function to know what the control is that is about to receive focus and react acordingly? -Joseph ...

Javascript without form?

Hello everybody. I'm building shopping mall website using Yahoo solution. My products have multiple options which are dependent on previous options. The problem is that in Yahoo, I have to locate options in the order form to appear in checkout page. Nested form doesn't work, of course. Here is one sample page: http://parseven.com/sample...

simplifying binding anonymous javascript functions to class

I have a rather large set of javascript functions that I am working on refactoring into a set of classes using Prototype. I was wondering if there was a way I could make binding anonymous functions to the class simpler? I keep forgetting to add the bind this at the end. Or is this just the way it is done all the time? var arr = this....

Can you set an Interval on button clicks?

$('.button').click(); The above code works great to click all buttons on the page at once, but I am trying to fire off clicks every half or second or so until the jQuery Object has looped i.e. $(function(){ $('.button').each(function(){ setInterval('$(this).click()', 500); }); }); Can some one tell me how I can d...

Unable to change global variable from local function

I'm trying to have a jQuery.getJSON() call change a global variable with the JSON array it returns var photo_info ; //Advance to the next image function changeImage(direction) { jQuery('img#preview_image').fadeOut('fast'); jQuery('#photo_main').css('width','740px'); if (direction == 'next') { ...

How can I include a div from another page?

Basically I'm trying to scrape a few divs out of several of the intranet sites at work. and include them on a page I run locally (so I can look at one page instead of having 5 open). I'm guessing this is possible with JavaScript but I'm primitive with JavaScript so I'm not sure what I need to search for to find the answers. After I scrap...

How can I fool a site that looks at the JavaScript object 'navigator' to see that I'm not on Windows?

I am trying to a website, however, it only works under Windows and Mac because they use the use navigator.platform from JavaScript to find out the architecture I run on. Of course, they also use the browser's user agent, but that was easy to spoof. Here is the .js in question: http://pastebin.com/f56fd608d. The code responsible for brow...

Needed: User drags 4 favorite images out of group of possibles into 1st Place Box, 2nd Place Box, etc..

Oh! Too many dragNdrops out there! Prefer the sleekest for my needs. DragNdrop images: I want my visitors to select exactly 4 favorites from a "corral" of, say, 8 jpgs. Dragndrop each from the bottom "corral" up and into 1st Place thru 4th Place Boxes... Unused images remain below, unmoved in "corral", blank space-holder if picture is ...

jQuery script not working when page viewed on localhost

I'm just starting to playing around on a Mac for the first time and have created a very simple html page that uses jQuery to do a simple text swap when an h1 tag is clicked. When I don't view the page through the webserver and just open it directly in Safari (file:///Applications/xampp/xamppfiles/htdocs/test/mypage.html) it works as ex...

Convert javascript for IE

I have a script that works fine in all browsers that I have tested so far (FF, Safari, camino, Chrome) but not in IE and I can't figure out why. The IE 8 (windows 7) debug utility highlights this section of the script: if(list[lineNum].getElementsByClassName("check")[0].getElementsByTagName("a")[0].getAttribute("title").search("Delete"...

Search JSON array for matching attribute.

I have a JSON array, I need to return a restaurant's name, but I only know the value of its "food" attribute (not it's index number). For example, how could I return "KFC" if I only knew "chicken"? restaurants = [ {"restaurant" : { "name" : "McDonald's", "food" : "burger" }}, {"restaurant" : { "name" : "KFC", "food" :...

JavaScript key listener disabled when inside a text form

I have a key listener assigned to the arrow keys to navigate a slideshow. But I want to disable the key listener, temporarily, while a user is typing inside an input field. How can I do that? My current code looks like this: //Listen to the keys function checkKey(e) { switch (e.keyCode) { case 37: changeImage('pre...

How can i get source from a minified javascript file?

I used online YUI Compressor for minifying my javascript file... Now i got minified version of it but i lost the source as i uploaded the source javascript file without taking a copy of it... How can i get source from a minified javascript file? ...

simple javascript question-linking button state to image swap?

Hi folks, I know this is a real newbie question, but that's what I am! I've been playing with ajax, and I have these two images swapping when I press the two buttons. Question: How do I make the button have the active state displaying while it's corrisponding image is displaying? I'm sure I need to do something like set an id on ...

Javascript trimAll() doesn't seem to work

When i executed this, var a = trimAll(document.getElementById("txt_msg").value); When i inspected through web developer toolbar I got the Error: trimAll is not defined.. Any suggestion... ...

how to close client pop up windows

How do I close all child popup windows which are already opened using jquery, after the user logs out? ...

Is it possible to interact with an embed movie via javascript ?

I am embedding a movie in a web page with the embed tag, but I would like to interact and be interacted via javascript with the embedded movie in .mov. In particular, I would like to get the timings so I can perform actions on the web pages when a particular moment in the movie is reached (like adding subtitles or karaoke effects in the ...

NS_ERROR_FAILURE

I'm trying to implement the basic XHR listener as described on "Ashita" however, when loading firefox with the extension I recieve this error on whenever a page tries to load which prevents anything from loading: Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIBinaryInputStream...

switching two ids with ajax callback

Hi folks, I was kindly helped by Jonathan over here http://stackoverflow.com/questions/2166912/simple-javascript-question-linking-button-state-to-image-swap The problem is that this makes the "active" class the same class for both list items. Each list item needs to toggle its own active and its own inactive class (each is a button wit...