javascript

Array functions in jQuery

Hi, I am using jQuery in my web-app I want to use arrays, but I am not able to find out functions for arrays (add, remove or append elements in array) in jquery, Can anyone share with me any link related to jQuery array functions which will explain the jquery array functions. Thanks ...

How to do this in jQuery

I have the following code: var tempIdx = document.getElementById('cityBuild').selectedIndex; var tempBuilding = document.getElementById('cityBuild').options[tempIdx].value; // Do stuff with tempBuilding I spent some time trying to do it in jQuery under the assumption it'd be easier, it wasn't. I tried what was given at this site but ...

JavaScript/CSS vs. Silverlight vs. Flex

We currently have a quite complex business application that contains a huge lot of JavaScript code for making the user interface & interaction feel as close to working with a traditional desktop application as possible (since that's what our users want). Over the years, this Javascript code has grown and grown, making it hard to manage &...

Div with scroll and content with absolute positions

I have a "div" with style: overflow-y: scroll; overflow-x: auto; I try to dynamicaly add image inside this "div" with absolute or relative position. Everything seems ok until user tries to scroll the "div" content: image stays in fixed position relative to browser window. This problem seems to be only in IE(7), in firefox everything is f...

In jQuery, what's the best way of formatting a number to 2 decimal places?

This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function? ...

How do I fix shocking/lagging movement in this ajax based multiplayer example?

EDIT: important, examples must be used in firefox 3+ due to html5 elements. Hi there, I'm trying to find out more about the potential of AJAX in a browser based multiplayer game. To do so, I'm testing out movement with AJAX and a space shuttle as a character. This space shuttle is rendered with canvas (html5). My first version is read...

accessing a form that is in an iframe

I'm trying to get access to a form and its elements. The form is within an iframe and the javascript code that is accessing the form is within the main document. I'm not sure what else I should put into the question, so please let me know if I need to add something else. (form and main page are in the same domain) Thanks ...

Rotating images, AJAX-like, in Ruby on Rails

I'm working on a site where I'd like to cycle images, similar to a slideshow, while the user is on the page. I've searched around and haven't been able to find a lead. Has anyone done this with Rails and the Javascript frameworks it supports? ...

Strange IE7 behavior with JavaScript window.open()

The following code was known to be working three weeks ago. In the interim we have installed IE 7 and a bunch of security patches. The ultimate question will be, does anyone know how to restore the old behavior? Scenario We have the following JavaScript code in web page 1 (let's call it foo.aspx), that is invoked on a button click: wi...

How to set the control value in another open aspx page

Hi! My problem is simple, but I cannot find a way to solve it :( When the user clicks a specific button, I need to open a new aspx page (in a new window) so that he is able to select something that needs to be returned to the original page. I was able to open the new page with window.open, however, I'm not able to set the selected valu...

Scrolling to a specific position

I currently have a map for the game I run, the map is already quite big and I'd like to make it possible to scroll to a position with Javascript. I have jQuery in use should that be helpful. Thanks ...

Javascript idiom for code structure

My javascript gets included multiple times with the script tag, like so: <script src="code.js></script> <script src="code.js></script> <script src="code.js></script> Right now I have this code inside code.js to make my code run only once without overwriting my namespaces: if(typeof _ow == "undefined" ){ _ow = {}; // code in here will...

Catch exceptions in jQuery

Hello, I have the following code: <script type="text/javascript"> $(document).ready(function() { $("#Save").click(function() { $.post("url", { "data": "data" }, function(data) { alert(data); }); }); }); </script> I'm testing this script, an...

How to select even or odd elements based on class name

if you create html layout like so <ul> <li class='a'></li> <li class='b'></li> <li class='a'></li> <li class='b'></li> <li class='a'></li> <li class='b'></li> <li class='a'></li> <li class='b'></li> </ul> and try to select odd elements with 'a' class like so $$('.a:odd') you will get empty array...

Browser "drag and drop" events: Can anyone fill in the blanks?

I've never really had the need to use any drag functions until now, so let me fill you in on what I've discovered so far: Drag events are events that take place when the user is dragging an object. This is "proper" OS dragging, eg: hiliting some text and dragging it, or even dragging in something from outside of the browser. While dr...

How are programmers tackling ie6 bugs these days?

I have been using dean edwards ie7/8 script. Not sure if it's my implementation or not but sometimes I would experience ie6 issues that weren't quite fixed or required special handling which meant I would be back where I started, caring about ie6. So, I was wondering if ie7/8 is still the go or if some other practice/solution was better....

Prototype.js and associative arrays

I have an associative array (object) of the following construction var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D'); menu['Submenu A']=new Object(); menu['Submenu A']['Option A']= 'foo blah text'; menu['Submenu A']['Option B']= 'blah more text'; menu['Submenu B']['Option A']= 'blah blah'; menu['Submenu B']['Option ...

snap.com snapshots disobeys Same Orgin Policy?

I'm trying to write some Javascript that shows data based on an HTTP GET request to a server on a different domain. From what I've read, this is made tricky due to the SOP (Same Origin Policy). I'm curious how snap.com "Snap Shots" (webpage previews) work. Here is an example page: http://premshree.livejournal.com/66129.html Could som...

deny browsers without javascript enabled to use my php site

Hi, Im writing a fairly small web application in PHP and intend on using DOJO to make it "fancy" and most likely handle some validation on the client side (there will be server side validation too). I would like make JavaScript a requirement for my site, and therefore, if a user's browser has JavaScript disabled, or is not capable of J...

Is Caja ready for production?

We're looking for a way to secure third party code within our web pages. Someone suggested we use Caja. I looked into that, but the information about it is quite sparse. Before I deep dive into it, I would first like to know: Can Caja handle embedded HTML like Google Map's, which effectively acts as a bootstrap, and loads all the activ...