javascript

Regexp: Remove quotation marks from json list

I've got an array of objects in json format: [{"name":"obj1", "list":["elem1", "elem2", "elem3"]}, {"name":"obj2", "list":["elem4", "elem5", "elem6"]}] Now I'd like to construct regexp to remove quotation marks from around elements in the "list" using javascript. Desirable result: [{"name":"obj1", "list":[elem1, elem2, elem3]}, {"name"...

Display Current Time each minute (with Prototype's Ajax.PeriodicalUpdater ?)

I have an app that display's the current time when a page opens. I would like that time to update every 30 seconds. I've read about prototype's Ajax.PeriodicalUpdater and it seems to be an answer. This is how I achieve the static time display on page load with php: <tr> <td> <input class="standard" type="text" name=...

javascript select() function with named anchor

I want to use the JavaScript select() function to highlight a text field on a form, but first I want to use a named anchor so the page will scroll to the proper section. The following code works pretty well in Firefox, (Unless you enter the same value twice,) but IE does not allow the highlighted text to be typed over (without a tab or a...

How do I do a Date comparison in Javascript?

I would like to compare two dates in javascript. I have been doing some research, but all I can find is how to return the current date. I want to compare 2 separate dates, not related to today. How do I do that. var startDate = Date(document.form1.Textbox2); ...

Safari & Javascript - Same Origin policy?

I have a Javascript that changes the host in links to match the current development/test server. Here's an example: var ndomain = document.domain; var mydomain = 'www.foo.com'; var alink = document.getElementsByTagName('a'); for (var i = 0; i < alink.length; i++) { if (alink[i].href.length > 0){ if (alink[i].host.substr(0, myd...

with just a plain html and js file, how can i force a link to an mp3 to download instead of just play?

i have a link to a media file such as an mp3, and i want it to get downloaded when the user clicks on it, instead of just having the file get played. the page i have in mind is just a plain static html page. any ideas? ...

How to call a client side javascript function after a specific UpdatePanel has been loaded

How is is possible to call client side javascript method after a specific update panel has been loaded? Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler) does not work for me because this will fire after ANY update panel finishes loading, and I can find no client side way to find which is the one ScriptMan...

How do I insert a DOM element in an ordered list (in Dojo)?

I'm trying to make an AJAXy submission and have the resulting partial be inserted into my list at the proper place. I can think of a few options, but none is terribly good: Option 1: Return JSON, do rendering in Javascript. That seems like the wrong place to render this, especially since the list itself is rendered in my application s...

Shared localization for asp.net, javascript and silverlight?

How do you localize ASP.NET + javascript + Silverlight? I would like to be able to include the same texts in different languages in asp.net pages, javascript on the page, and Silverlight objects on the page. I have tried with the following method, but have no experience with it in practice, and I would like to hear your opinions on it ...

Javascript form validation

Hello, I'm trying to figure out what would be the simplest way to validate required fields without having to do an if statement for each element's name. Perhaps just with a loop and verify its class. What I'm trying to accomplish is to check only the ones that have the class name as "required" <input name="a1" class="required" type="te...

Does Javascript fire an event for unhandled/uncaught exceptions?

I'm looking to log unhandled javascript exceptions. Is there an event that fires when an exception isn't caught? I'm looking to catch the exceptions before they cause javascript errors in the browser, but I'd rather not run my entire application inside of a try/catch. Any help would be appreciated. Thanks! Update: tvanfosson pointed ou...

Edit a file using javascript

Hi friends, I need to edit a xml file using javascript. Now i involved in a project of online test. The question.xml file is already in the project folder. In that i want to add or edit the questions(only using javascript). I can able to bring the particular content through ajax but i cant able to edit the file. Please help me to e...

Transfering sensitive information from javascript to rails

I am currently writing a Firefox extension that will sync your tab sessions across different instances of the browser. I am using a Ruby on Rails web application to sync the different URLS for each user. The Firefox extension is using Javascript to parse out the current websites that are open. I need to send a user's login name, passw...

Is there a built in Javascript function to turn the text string of a month into the numerical equivalent?

Is there a built in Javascript function to turn the text string of a month into the numerical equivalent? Ex. I have the name of the month "December" and I want a function to return "12". ...

Javascript memory leak cleanup in window.unload

Javascript client side application. Trying to eliminate memory leaks leads to ugly (to say the least) code. I am trying to clean up in window.unload instead on messing up all the code trying to avoid them. We use mostly element.onevent=function(){..}; pattern, that results in closure (mostly wanted) and memory leak. We do not use jav...

Visibility of script includes in an IFRAME

For example: script.js: function functionFromScriptJS() { alert('inside functionFromScriptJS'); } iframe.html: <html> <head> <script language="Javascript" src="script.js"></script> </head> <body> <iframe> <body> <script language="JavaScript"> functionFromScriptJS(); </script> </body> </iframe> </body> <h...

Best way to include unobtrusive information on a web page

So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <head> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page. However, I have some exact co-ordinate data for each address which the javascript requires to place the markers c...

How do I add an option to a select box in a parent window using jquery?

In my child window I have $('#opfile').addOption("someval",sometext"); Problem is #opfile is an a parent widow I cant get it to communicate I tried window.opener.$('#opfile').addOption("someval",sometext"); but no luck any ideas? Update Embarssing but I got the above to work might have been caching something Thanks for the sugg...

Clicking twice to activate? javascript onclick issue

Hi! I'm having an issue with a project I am working on at the moment that is making use of the Validation plugin for jQuery, when the validation error appears I am dynamically applying an anchor tag to it with an onclick. And its this onclick thats the problem... The first time the validation error appears I have to click the link twic...

Opener.Location.Reload(); displayed Permission denied error in java script

I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting Permission denied javascript error. Any ideas about this issue. ...