javascript

Strange javascript error when using Google Image Search API

I'm trying to copy the Google image search from this page. Here is my code: <script type="text/javascript"> <% if @note.text == "" %> google.load("search", "1",{"callback":searchCallback()}); <% else %> google.load("visualization", "1",{"callback":dummyFunction}); <% end %> function se() { var sF...

Javascript combining a reg expression and string

Hello. I have a string which contains a nonvariable part, a variable numnber and another nonvariable part. I want to user replace(), to change only the variable part into a value a user chooses. I'm a noob at javascript, and even a bigger noob in reg expressions, so sorry if this is something trivial. Anyway, i have a string like this: ...

Open/Save file in javascript

I'll write an app that'd need to let user load PNG&JSON files and then save them. How could I let user open and save such files? I wouldn't like to write up an echo server for those images. ...

JavaScript history control targeted at iFrame affecting parent

I've just noticed that my JavaScript history control targeted at a iFrame is affecting the parent. The code is: document.getElementById('iframeid').contentWindow.history.back(-1); document.getElementById('iframeid').contentWindow.history.forward(-1); It works fine, until there is nothing to go back or forward in the iframe, where then...

How to extract info from json output.

Hi, I have a json output that looks like this.. { "XXXX": { "name": "Dalvin Nieger", "work": [ { "department": { "name": "Sales" }, "start_date": "0000-00" } ], "link": "http://www.my-site.com/profile.php?id=XXXXX", "id": "XXXXXX" }...

An architecture for almost complete JavaScript-based web applications?

Hi, I know that MVC is highly acclaimed for PHP applications, but I am not sure at all that it fits in JavaScript. If you think otherwise, then please explain how and where you handle common scenarios like AJAX requests, data saving (offline storage), presentation, how do you handle controller logic (do you have a front controller?), an...

What's the best way to prevent a browser from displaying images until they are fully loaded?

I would like to set up a lean and mean image gallery, with thumbnails displayed inline. I'd like them not to windowshade in while loading, I'd like them to simply pop up or, if there's a way to detect their completion, use a jQuery effect like a quick fadeIn(). I imagine a line of code like: $(".thumb-image").whenLoaded(fadeIn(500))...

Analytics for 3rd party JavaScript widgets

I'm trying to find the best approach for analyics on 3rd party JavaScript widgets - i.e. tools and content that is distributed to any number of arbitrary users, who include the widgets as HTML snippets with tags. On the same domain Note that the widgets do not load into an iframe element that has a document loaded from the external si...

Switching from JQuery to RightJS

I am currently using JQuery and recently heard about RightJS. RightJS seems to be faster, lighter & more object oriented. But I was wondering if RichJS has somethings seriously missing compared to JQuery (Other than the huge plugin base). Update: I tried RightJS in a small web project & decided to use it on a few more projects. But I ...

assign each elem of an array of values to each element in an array of elements jQuery

When I do $('#conatiner1 span') on my page, it returns an array with 11 span elements. I also have an array 'vals' with 11 different values. Is there a fast 'do more, write less' jquery command to easily assign each value of val to each span element? span 1 -> val 1; span 2 -> val 2; span 3 -> ... ...

Jquery .get() - How to pass the value of a text box into the data parameter?

There is one form with a textbox id="name" and a button. After the user clicks the button, I want to execute the $.get() to capture the reply. (I got the .click() correctly so far) How to I pass the value the user enters to the text box as the {data} parameter in the get function? Thank you! ...

Question in Chrome Extensions Sample

Can anyone explaing me this line in detail? // Find all the RSS link elements. var result = doc.evaluate( '//*[local-name()="rss" or local-name()="feed" or local-name()="RDF"]', doc, null, 0, null); Best Regards, Cetin ...

Set the webkit-keyframes from/to parameter with JavaScript

Is there any way to set the from or to of a webkit-keyframe with JavaScript? ...

Detect FLASH plugin crashes

Is there any way to detect flash-plugin crashes in major browsers (firefox, ie, chrome, safari and opera) via javascript? ...

Cross Domain JavaScript, issue with parent.window.location.hash on chrome and safari

Hi All, I am working on Cross Domain JavaScript technique called "Fragment Id Messaging". M using parent.window.location.hash for attaching "#" to window location from inside iframe. This is working fine with firefox but not working on chrome and safari. any idea? solution? ...

How do I build a page preloader for a php page?

Hi guys, I want to include a page preloader for all pages on my application. Something like what Gmail displays when its loading the entire page in the background. I don't want a prelaoding bar just the mechanism to display immediately a preloading message while the entire page loads in the background and upon successful load is displaye...

[javascript] EXTENDS challenge: preprocessor function macros and class-like oop

Background I've been using the C preprocessor to manage and "compile" semi-large javascript projects with multiple files and build targets. This gives full access to C preprocessor directives like #include, #define, #ifdef, etc. from within javascript. Here's a sample build script so you can test the example code: #!/bin/bash export OP...

Get unrecognized styles from stylesheet in JS

How can I get the actual text of a stylesheet using JS? The cssRules property only returns those rules that it recognizes. eg. I would like to change -webkit-border-radius to -moz-border-radius. Or do some JS wizardry to any element who's style contains myTrigger:true; (Do NOT lecture me on principal.) Cycling through document.styles...

How to set the value for form fields.

Hi, I want save multiple individual records for a single model. So my form will have <input> elements with IDs that look like this Author0Title; Author1Title; Author2Title, etc. I will be getting values for these input's using jQuery.getJSON() method. I want to assign individual values for these input like these automatically. docum...

jQuery: delay() or timeout with stop() ??

hey guys, $('.file a').live('mouseenter', function() { $('#download').stop(true, true).fadeIn('fast'); }).live('mouseleave', function() { $('#download').stop(true, true).fadeOut('fast'); }); i want the mouseenter function to have a stop() and a DELAY of like a 1sec. So if i hover over #download the fadeIn should start 1second ...