javascript

Confusing JavaScript statement: "var x = new this();"

Hi everyone, I thought I understood the concept of the JavaScript prototype object, as well as [[proto]] until I saw a few posts regarding class inheritance. Firstly, "JavaScript OOP - the smart way" at http://amix.dk/blog/viewEntry/19038 See the implementation section: var parent = new this('no_init'); And also "Simple JavaScript ...

Match a specific sequence or everything else with regex

Been trying to come up with a regex in JS that could split user input like : "Hi{user,10,default} {foo,10,bar} Hello" into: ["Hi","{user,10,default} ","{foo,10,bar} ","Hello"] So far i achieved to split these strings with ({.+?,(?:.+?){2}})|([\w\d\s]+) but the second capturing group is too exclusive, as I want every character to be...

Best way to convert string to array of object in javascript?

Hi guys, I want to convert below string to an array in javascript. {a:12, b:c, foo:bar} How do I convert this string into array of objects? Any cool idea? ...

Implementing a client-side image editor - what's the best way?

We want a web app that allows a user to edit images on the browser and we're trying to decide which technology to use. We want to support simple image customization, such as high-quality resizing, cropping, image merging, and color transformations, as well as the addition of text elements with different fonts and colors. The current opt...

What's wrong with javascript (toFixed) method?

What's wrong with this code? var result = 985.toFixed(2); And the fix is: var result = (985).toFixed(2); I still want to know the reason. :) ...

Type of iPhone/iPad/iOS application - modal view, tabbed, other?

Hi - I'm making my first iOS application to be run specifically on an iPad as part of my final year project at University. I've been experimenting with the different types of applications and I'm stuck wondering what would be the best type for my application - the application is to quote for a service offered by a local business, they ...

Intelligent date range parsing of human input?

Has anyone come across a script / cl app written in any language that handles the parsing of human-entered dates well? I'd love to be able to parse, for example: "3 to 4 weeks" "2 - 3 days" "3 weeks to 2 months" ...

Set focus to validation summary ?

Hi I have an aspx page, where there are 2 validation summaries. One for master (at the top of page) & one for details (at the bottom). On details validation, the focus just shifts on top of the page and not on my validation summary in details section. How to do this ? Any clue guys ? ...

difference between window, top, parent

I just noticed that top, window and parent variables are giving me the same value. I was testing this at gmail inbox page. Any body knows what is the difference between these three values? ...

window.onload vs. body.onload vs. document.onready

what is the difference between window.onload, document.onready and body.onload ...

Configure widgets positions on website

What is the commonly accepted way so an admin can set panels/widgets positions (i.e. from the image below, set "Data Finder" to sit on "top left") ? In other words, the customer/admin would like to be able to configure the widgets/panels positions at startup (and users see that by default), maybe using a JSON configuration file that is ...

replace / with "" and " " with %20 in one go on a javascript variable?

Hi, I insert some strings in an array but before I do that I want to do what topic says. To only replace space with %20 I do: Name.push(linkText.replace(" ", "%20")); But how do I perform two "replace" there in one go? Thanks in advance ...

dynamic form validation

i'm creating select box dynamically in php .i can add this select box at the back end. so how can i validate that select box without knowing name of feild. kindly help me with javascript if any one have idea about that thanks ...

Forcing a reload in JQuery

I am making use of the Lavalamp plugin from http://nixboxdesigns.com/projects/jquery-lavalamp/ and everything seems to be working fine except that there is a little quirk when using the back button. For example: If you are starting off from the home page, the hover is underneath the home menu. Click on a new menu item, the hover appea...

Difference between two regex pattern in javascript

Hi folks, I my application I am using below regex for pattern matching. Original Pattern : /(\w+\.){2,}/ig Above pattern added in one array. Since this pattern has comma ( , ) after 2, creating problem in some environment. As we know below concept in regex : {n} - matches n times {n, m} - matches at least n times, but not mor...

Silverlight 4: OnBeforeUnload

I have a silverlight application and I want to capture the close event of the browser. So what I did, in my .aspx page i have this code function closeIt() { return "Any string value here forces a dialog box to \n" + "appear before closing the window."; } window.onbeforeunload = closeIt; If this functions trigger...

how to access variables in closures if there are local variables with the same name?

I took this from Google Code Playground http://code.google.com/apis/ajax/playground/ /*CLOSURE * When a function is defined in another function and it * has access to the outer function's context even after * the outer function returns * An important concept to learn in Javascript */ function outerFunction(someNum) { var someSt...

IE8 Javascript Error

I have written a js method which runs perfectly on FF. This js method is called on the click of a radio button. In IE, when I click the radio button, the js method is called only when I click somewhere on the form. I have no idea about this strange behavious in IE. Any ideas? Thx Here is my code. xmlns:h="http://java.sun.com/jsf/h...

why the height of a frame is not constant in ie7

i was developing a page which has two frames, the left frame is a treeview file, when click one of the file it will display on the right frame.the main page code is below <frameset id="main_frame" cols="210,*" rows="*"> <frame src="FramesetLeftFrame.jsp" id="treeframe" noresize="noresize"/> <frame src="" id="ba...

What is the current state of the art in HTML canvas JavaScript libraries and frameworks?

I am currently investigating options for working with the canvas in a new HTML 5 application, and was wondering what is the current state of the art in HTML canvas JavaScript libraries and frameworks? In particular, are there frameworks that support the kind of things needed for game development - complex animation, managing scene graph...