javascript

What are the ways to minimize page wait from external javascript callouts?

What tricks can be used to stop javascript callouts to various online services from slowing down page loading? The obvious solution is to do all the javascript calls at the bottom of the page, but some calls need to happen at the top and in the middle. Another idea that comes to mind is using iframes. Have you ever had to untangle a s...

Repeat String - Javascript

What is the best or most concise method for returning a string repeated an arbitrary amount of times? The following is my best shot so far: function repeat(s, n){ var a = []; while(a.length < n){ a.push(s); } return a.join(''); } ...

Saving the time the user is logged on.

In the application I am developing I have to store the time some particular users remain logged into the application, unfortunately, in web applications there are several ways the user can log off. 1.- User clicks log off. 2.- User session expires. 3.- User closes the window. 4.- User types another site url in the address bar. The firs...

Use javascript to inject script references as needed?

I have a JS function that may occasionally get used on some pages. It is dependent on another JS file (swfObject.js), but I'd like to avoid having to include this file all over the place, as thats a wasted request most of the time. Instead, I'd like to create a generic function that can inject a script reference into the page DOM as nee...

How to get around a 'NS_ERROR_ILLEGAL_VALUE' error using Ajax?

Im just writing a small Ajax framework for re-usability in small projects and i've hit a problem. Basically i get a 'NS_ERROR_ILLEGAL_VALUE' error while sending the request and i've no idea what is happening. The HTML Page (trimmed but shows the error) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml...

Integrating "really simple history" with Rails

In trying to solve the "ajax back button" problem I have found the Really Simply History library. Has anyone tried to integrate it with Rails? It's plain old javascript so it seems like it should integrate just fine, but I know next to nothing about JS itself, so I'm not too confident in trying to do the integration without a tutorial...

using a named function as the callback for $.getJSON in jQuery to satisfy Facebook request signing demands

I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing the request url on the server side (in order to keep my app secret secret). I'm then sending the url over to the browser to be request using jQuery.getJSON(). Facebook requires that I send a copy of all of my request params hashed with my a...

Is it possible to get Message Box in web forms?

I tried but I guess Message Box only works with win forms. What is the best alternative to use in web forms? ...

Why does instanceof return false for some literals?

"foo" instanceof String //=> false "foo" instanceof Object //=> false true instanceof Boolean //=> false true instanceof Object //=> false false instanceof Boolean //=> false false instanceof Object //=> false // the tests against Object really don't make sense Array literals and Object literals match... [0,1] instanceof Array //=> t...

How do I debug javascript in visual studio when an asp.net application is run under firefox?

How to debug javascript in visual studio when an asp.net application is run under mozilla firefox browser? IE supports by enabling javascript debug option . ...

What tool to use for JavaScript development?

So far I've used Dreamweaver and Eclipse to develop my JavaScript code and tried a bunch of others. And let me say I'm not impressed. I'd like to think there are better tools out there. Tools that could, for example, give me a hint that something is wrong when I type document.geElementsById before I "build" and test my project. Maybe i...

When loading a page containing flash or javascript, I get a security error message...

"To help protect your security, Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer" Whenever I add flash movies or javascript code this message will show. It also shows for somebody else, so how do I get rid of this message? If I load or access some other website whi...

Moving items in Dual Listboxes

How can I move items from one list box control to another listbox control using JavaScript in ASP.NET? ...

Spreadsheet-like control for a web application?

A client of mine is looking to convert a critical 'application' based on multiple (very complex) spreadsheets into a web app. As part of this they'd like some of the web pages they use to enter/model data to resemble a spreadsheet as much as possible. I'd be interested to know if anyone has any experience/recommendations for embeddable...

Are there any tools to transform SVG data to Canvas friendly input?

Are there any tools to transform SVG (XML) data to Canvas friendly input? ...

Destructuring assignment in JavaScript

As can be seen in the Mozilla changlog for JavaScript 1.7 they have added destructuring assignment. Sadly I'm not very fond of the syntax (why write a and b twice?): var a, b; [a, b] = f(); Something like this would have been a lot better: var [a, b] = f(); That would still be backwards compatible. Python-like destructuring would...

JSMX ajax API not passing form variables to page with ie7

I have a couple of pages working with Firefox but JSMX isn't passing the form variables through when using IE7. Has anybody experienced this? ...

How do I add ajax calls to Mootools class

I have modified (very slightly) the Mootools class noobSlide (http://www.efectorelativo.net/laboratory/noobSlide/) to create a flickr style photostream. Here is the modified html (note you can see the original on the above page) print("code sample");<h2>Sample 2</h2> <div class="sample"> <div class="mask4"> <div id="box2"> <span><im...

Does it still make sense to use HTML comments on blocks of JavaScript?

In the past people used to wrap HTML comment tags around blocks of JavaScript in order to prevent "older" browsers from displaying the script. Even Lynx is smart enough to ignore JavaScript, so why do some people keep doing this? Are there any valid reasons these days? <script type="text/JavaScript"> <!-- //some js code --> </script> ...

How do I automatically remove an HTML page frame?

What's the best way to remove a page frame automatically? I've used this type of code before: <script language="JavaScript"> setTimeout ("changePage()", 3000); function changePage() { if (self.parent.frames.length != 0) self.parent.location="http://www.example.com"; } </script> ...