javascript

Matching one-line JavaScript comments (//) with re

I'd like to filter out (mostly one-line) comments from (mostly valid) JavaScript using python's re module. For example: // this is a comment var x = 2 // and this is a comment too var url = "http://www.google.com/" // and "this" too url += 'but // this is not a comment' // however this one is url += 'this "is not a comment' + " and ' ne...

Can you alter a Javascript function after declaring it?

Let's say I have var a = function() { return 1; }. Is it possible to alter a so that a() returns 2? Perhaps by editing a property of the a object, since every function is an object? Update: Wow, thanks for all the responses. However, I'm afraid I wasn't looking to simply reassign a variable but actually edit an existing function. I am t...

too much recursion in javascript with jquery mouseover

I am a JS novice. Using some code I found here to help me with mouseover scale/rotate images but now when I try to apply it to more than one object I'm getting errors saying "too much recursion". Before the function didn't take any arguments, it just was on s_1 and it worked fine. I am tempted to just write different code for each object...

How can I filter a FileDialog depending on a dropdown selection?

I think this is a two-in-one question.. one, is: How do you filter valid file types in a FileDialog for a Html page? Im using ASP.NET MVC and currently showing the textbux/browse button this way: <%= Html.TextBox("Order.LoanInfo.FilePath", null, new { style = "width: 800px;", type = "file" })%> and the second is : How could you do to...

jquery select remove undefined?

Hi, I using jquery how do i remove the one of the elements of the select dropdown where the value <option value=" ">undefined</option> i tried $("#subType option[value=' ']").remove(); $("#subType option[value='']").remove(); None of them worked. Please advise. ...

Javascript replacing new line character

This is driving me crazy, I have a string in the format: <br /> twice<br /> imap Test wrote:<div class="nestedMessage1"><br /> > nested<br /> ><br /> > [email protected] wrote:<div class="nestedMessage2"><br /> >> test<br /> >><br /> >> -- <br /> >> Message sent via AHEM.<br /> >> </div><br /> ><br /><br /></div> And the following cod...

How to manage CouchDB code out of it?

I am new to CouchDB way of making things. So, I have a lot of questions about it, but let's focus in one of them. CouchDB has this concept of javascript code (validation + map-reduce + show + ?) being written in the design documents. This is part of the database, like stored procedures or triggers are for more tradittional databases. I...

JavaScript Array Initialisation in Simple JavaScript Inheritance

I'm currently working on some code based on John Resig -Simple JavaScript Inheritance. And i'm having some trouble with the initialization of arrays. If i put an array as an attribute for an object and don't initialize the array during the call of init(), all the modification made to the array like push, unshift will affect further crea...

Animate PNGs with jQuery?

Is there a simple plugin or some robust code that would allow me to animate PNGs with a simple start and stop method? TSM, Alex. [Edit: I made a jQuery plugin that animates PNGs. Will post when it's all done.] ...

Selenium extensions: "blocking" commands

Is it possible in selenium to write blocking commands? I want to make a "clickAndWaitForAjax" command. It will click a button and wait until a div is filled with text from the server. It is clear to me this can be done with two commands, but can it be done with one? How? ...

Javascript Engines

I am confused about javascript engines right now. I know that V8 was a big deal because it compiled javascript to native code. Then I started reading about Mozilla SpiderMonkey, which from what I understand is written in C and can compile javascript. So how is this different from V8 and if this is true, why does Firefox not do this? Fin...

javascript function save to cookies

For now, i have a function macs, and i need to implement this function to save inside a cookie and have it stored in mysql.. So how am i supposed to have this function together? <script language="JavaScript"> function getMacAddress(){ document.macaddressapplet.setSep( "-" ); return (document.macaddr...

How should I design my application so that it is easy to offer multiple languages?

I am currently building an web app using mostly PHP and JavaScript. What is the best way to design an app so that it is easy to make it available in multiple languages? Originally it will only be in English but I may want to make it available in other languages in the future. ...

How to prevent CSRF/XSRF attacks involving embedded iframes?

Is there a way to restrict what an iframe is allowed to do in the parent? What I am looking for is a security model surrounding Javascript that looks something like: ... <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> function AllowedToAccess() { } function NotAllowedToAccess() { } </...

Is there any reason why a json would on return the last object in the string when eval'd

I have a json string that when I put it into the eval function it only returns the last object in the string. Anyone possibly know why ...

Banner Management System using Rails

I want to create an open source banner/advertising management app using Rails. The app is like the simplified version of OpenX, where user can define the ad zone, upload banner, and paste the javascripts on the page to view the ads. This will be my first open source project and using this opportunity to learn Rails. But I searched aroun...

YUI MenuBar not showing submenus

So I'm trying to learn the YUI toolkit, and I'm having issues with my menubar having usable submenus. If I use the following code: <html> <head> <title>Web</title> <!-- Yahoo UI --> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.0r4/build/reset-fonts-grids/reset-fonts-grids.css&amp;2.8.0r4/build/base...

Anonymous Functions in JavaScript

var a = function(){ return 'test'; }(); console.log(a); Answer in First Case : test var a = (function(){ return 'test'; })(); console.log(a); Answer in Second Case : test I am using the the first approach to create self-executing functions. However, I have seen the second approach as well. I...

A static row in an HTML table

I'm trying to create a file listing a la windows explorer in HTML/Javascript. As such, I'd like the first row of the table, which contains the headings for all the columns, to be visible even when the columns are scrolled. I've tried a few options involving placing the headings in a separate table, but all have failed for primarily one ...

How to handle the absence of Flash in a browser

Hi, Please can somebody explain to me how to render a static banner instead of a flash banner in the event that the browser doesn't have Flash installed already, so as not to interrupt the user's browsing experience. I'm coding in PHP and it probably makes sense to test for this in IE as well as Firefox. Thank you ...