javascript

Best way to determine user's locale within browser

I have a website (Flash) localized into a dozen of languages and I want to auto-define a default value depending on the user's browser settings in order to minimize the steps to access the content. FYI, I cannot use server-scripts due to proxy restrictions, so I guess JavaScript or ActionScript would be appropriate to solve the problem....

Can the iframe access its parent if i changed its src to "about:blank" after loading it in the parent page?

Can the iframe access its parent if i changed its src to "about:blank" after loading it in the parent page? Note: the iframe is in another domain not the same as the parent page. ...

Distribute elements evenly using CSS

A method to distribute elements evenly in a container using CSS appeared on Smashing Magazine today. I recently had to use Javascript to achieve the same effect for elements of variable width, but the method presented on SM made me wonder if it was possible to do this without Javascript. There's this question, where gargantaun says: ...

Returning google.visualization.DataTable from Javascript Function

I'm working on a page that brings in various data from a google spreadsheet, and need to loop in order to draw multiple visualizations from multiple queries. In order to do this I'd like to run a loop which queries the spreadsheet alters returned data to fit my needs graphs the altered data. I've tried multiple techniques, after alt...

How to support multiple text selections cross browser?

I am building a web-based annotation tool, where end users can select and annotate a section of text from an HTML document. Programmatically speaking, accessing and working with the selected text and corresponding range is straightforward using "window.getSelection" and "getRangeAt". I am running into a problem, however, when I try to...

Embedding an image in an AJAX response

Is it possible (and supported cross-browser) to embed an image into the XML of an AJAX response, and then load that image using JavaScript? I have a system that does some calculations based on the number of sessions running through it. The results are then graphed, and returned in two parts: 1) XML containing information about the grap...

Javascript debugger issue in VS2008

I'm having a really annoying problem with debugging javascript with VS2008. If I simply press F5 (or choose 'start Debugging' from the Debug menu), the iexplore process is attached, but no breakpoints break in the scripts. The Script Documents tree doesn't even appear in the solution explorer. I already know: I can set a breakpoint i...

xmlHTTPrequest won't open ("GET" , url, true); I'm miffed! PHP

I've been trying to get a url to open but I'm miffed as to why this hasn't worked. The code is listed and explained below. Any help will be deeply appreciated. The object: function getXMLHTTPRequest() { var req = false; try { /* for Firefox */ req = new XMLHttpRequest(); } catch (err) { try { /* fo...

Time Zone JS, need help with formatting

This code displays times zones vertically. I would like to display them horizontally but with appropriate spacing. I want to replace the 'br' break tag (second to last line of code) with a tag that will provide spacing between a new name and zone.   does not work. Simple but tricky for some reason. <!DOCTYPE HTML PUBLIC "-//W3C//DTD H...

Persist nested jquery sortable list

The Problem: I have a nested list on my configuration page that looks like this: <a id='Save'>Save<a> <ul id='configuration-list'> <li id='e1'>Elem A <ul> <li id='ey'>Elem Y </li> <li id='ex'>Elem X <ul><!-- and so on until 5 levels of nesting --></ul> </li> <li id='ez'>Elem...

Regarding JavaScript for() loop voodoo...

I was for quite some time under the impression that a for loop could exist solely in the following format: for (INITIALIZER; STOP CONDITION; INC(DEC)REMENTER) { CODE } This is, however, most definitely not the case; take a look at this JavaScript implementation of the Fisher-Yates Shuffle: shuffle = function(o) { for (var ...

How do I subtract minutes from a date in javascript?

How can I translate this pseudo code into working js [don't worry about where the end date comes from except that it's a valid javascript date]. var myEndDateTime = somedate; //somedate is a valid js date var durationInMinutes = 100; //this can be any number of minutes from 1-7200 (5 days) //this is the calculation I don't know how ...

Frames, scripts, and load order

If I have a document with a frameset and some javascript defined in a head tag, i.e something like this: <html> <head> <script> function foo() {} </script> </head> <frameset> <frame src="A.html"> </frameset> </html> I am already assuming that the frame (A.html) fires its onLoad event handler before that of its...

JS Variable Scope

Variable scope in JS is confusing the hell out of me. In follwing code, if i use the setClient public method to set a clientID i can then access the value from inside the track method using the getClient method. I cannot however access the value of the private member 'version' this way (or any other private member).. i had assumed that v...

How can I access runat="server" ASP element using javascript?

It seems everyone is doing this (in code posts etc.)...but I dont' know how :( whenever i try to manipulate an asp element using javascript i get a "element is null" or "document is undefined" etc. error..... javascript works fine usually,...but only when i add the runat="server" attribute does the element seem invisible to my javascri...

inspect javascript calls for gmail's buttons

i'm working on a greasemonkey script for gmail in which it'd be very useful to know what function call is made when the "send" button is clicked. (i was unable to find this using firebug, but am relatively new to javascript debugging.) it seems that one should be able to detect this, i just don't know what tool(s) to use. thanks very mu...

Javascript menu conflict

I'm having a Javascript conflict. I have a vertical javascript left nav menu and a horizontal javascript time zone menu. Working code for both but when I call them within the same page, the menu tree does not work. If i take out the <SCRIPT src="timezone.js" type=text/javascript></SCRIPT> tag the menu works fine but the time zone is nega...

Is it possible to implement properties in languages other than C#?

During a bout of C# and WPF recently, I got to like C#'s properties: public double length_inches { get { return length_metres * 39.0; } set { length_metres = value/39.0; } } Noticing, of course, that length_metres may change from being a field to a property, and the code need not care. WPF can also bind UI elements to object p...

How do I access properties of a javascript object if I don't know the names?

Say you have a javascript object like this: var data = { Name: 'Property Name', Value: '0' }; You can access the properties by the property name: var name = data.Name; var value = data["Value"]; But is it possible to get these values if you don't know the name of the properties? Does the unordered nature of these properties make it...

Firefox page "moves" when hiding/showing divs

We have a web page with this general structure: <div id="container"> <div id="basicSearch">...</div> <div id="advancedSearch" style="display: none">...</div> <div> With this CSS: #container { MARGIN: 0px auto; WIDTH: 970px } #basicSearch { width:100% } #advancedSearch{ width:100%;} We have a link on the page that lets the user ...