javascript

Signing data with PKCS #7 (opaque) for the web

Abstract: Is there a way, either via Firefox plugin or other means to emulate javascript crypto.signText using an opaque algorithm instead of detached (what it currently does?) to sign arbitrary data. This includes the dialog box and access to the Firefox cert store. Also, the signText documentation doesn't seem to have been updated sinc...

Jquery nested ajax call remember first HTML response in inner ajax call

Ok. I need to do something like this: 1) Make a GET ajax request and remember the HTML response in a variable. 2) Inside this first ajax request (in the callback function) I need to make a second POST ajax request and append the HTML response to the remembered HTML response from the first request. 3) Replace a div with the HTML from the...

How to do blocking calls in Javascript (with Narrative Javascript)?

Hello, I am trying to understand the usage of resultNotifier of Narrative JavaScript. I wrote the code below (HTML & njs). When the code is running it displays 2 alert windows that come from these 2 instructions: alert(notifier); ------------------------> [object Object] alert(" value = " + value); --------> value = [object Object] ...

Scope within an object literal

Hi Folks, I'll start with an example snippet: self.addwidget({ box: ns.box({ text: 'Foobar', fromTop: ~~(Math.random()*window.innerHeight), fromLeft: ~~(Math.random()*window.innerWidth), toTop: 240, toLeft: ...

Google Maps - using geocoder to get long/lat with javascript

I'm trying to get longitude and latitude values from the google maps api with an address, however it doesn't seem to be returning any value. Is there a problem with my syntax? var point = GClientGeocoder.getLatLng('1600 Pennsylvania Avenue NW Washington, DC 20500'); alert(point); ...

web workers: how to know if the browser supports it ?

What's the best way to know if the running browser supports web-workers ? is it try { new Worker(); } catch (e) { /* it does not */ } Thanks ...

JavaScript variables declare outside or inside loop?

In AS3 I believe you should initialise all variables outside loops for increased performance. Is this the case with JavaScript as well? Which is better / faster / best-practice? var value = 0; for (var i; i < 100; i++) { value = somearray[i]; } or for (var i; i < 100; i++) { var value = somearray[i]; } ...

How do I insert attributes into an array?

Each element in $(some_selector) has attribute my_attr (which is a number). I would like insert all these attributes to array. What would be the easiest way to do this using jQuery ? ...

Twitter OAuth callback issues for web widget

Our website lets users create small widgets that can be embedded on other third party sites. When an end-user interacts with our widget on some site, we want to post a twitter update on his/her behalf and then display a message to the user on the widget itself(provided the twitter update was successful). We've been using the twitter api ...

jQuery paging plugin that works with odd~ish page structure

I've added a jQuery plugin to our websites that currently works as desired, however it breaks when there's two elements on the page that needs to be paged. I've asked the developer of the plugin about this, and he confirms it's been designed with only one element on the page. So, I've went out to look for another pager plugin, but all o...

How to continue javascript execution when receiving errors during load

Not sure the best way to phrase the question, but suppose you are using jQuery to setup various things like so: <script> function doSecond(){ alert("Hi"); } function dofirst(){ var x = asdasd; } $(dofirst); $(doSecond); </script> So, imagine that dofirst and dosecond are completely indepe...

Setting mouseover within a script

The script I have been working on for a star rating system, saves the filled in stars with an onClick event and changes the onmouseover & onmouseout values to null so moving the mouse off them afterwards won't mess that up, and the form has multiple ratings and a clear button at the bottom, which i need to have reset the onmouseover & on...

Javascript Navigator Object

If I write this: navigator.plugins I get this: [object PluginArray] If I write this: navigator.plugins[0] I get this: [object Plugin] How can I get the real name of the plugin. Same is true for: navigator.mimeTypes Thanks ...

Unable to type in textbox even with focus set

I have a flash keyboard (not written by me and I know no flash) which is used by the users to type in to the web forms. The keyboard works fine and I am able to fill the fields properly. When the keyboard obscures any field, I am scrolling the document (in EnsureNotObscured() method) so that input field is not obscured. This is where I...

JavaScript Error

could someone give me an extra pair of eyes on this and tell me what is wrong? Problem at line 262 character 9: Implied eval is evil. Pass a function instead of a string. setTimeout("dojo.addClass(dojo. byId('transition'), 'hide')",1380); ...

Can't find JavaScript Syntax Error

Hi there, I'm just about to freak out. I currently have to work on a website that some other guy did and I am asked to maintain etc. It uses jQuery and a bunch of drupal modules. At some point i get some syntax error, so that some js works, and some does not. My big big problem is to find the syntax error. Neither Firebug, nor WebInspec...

How to disable a function temporarily in JavaScript?

I am trying to disable a function in JavaScript so that it only can be called once every 300ms. To do this, I guessed the best approach would be to do sth like this: var locked = (function () { var lock = null; return function () { if (lock != null) return false; lock = setTimeout(function () { ...

Javascript Source Missing

In java script I am including a source file like usual <script src="http://source.com?file=1" type="text/javascript"></script> The problem is that sometimes the file is not accessible and it throws an exception. Is there any way to include a file like this but if its not available catch the exception and navigate to a new page? I don...

Is there unique() function in javascript to remove similar elements in array of numbers ?

I have an array of numbers, like: [1, 4, 7, 1, 2, 1, 3, 1, 4]. I would like to remove duplicate elements and sort the result, i.e. the required result is: [1, 2, 3, 4, 7]. Is there any built in Javascript/jQuery functions to do this, or I must write my own ? ...

JavaScript history.back() conditionally

My website uses asual address plugin for implementing hash based URL. On one of the pages I have placed a back link. I want the following behavior on click of this link. $('#back_link').click(function(){ If there is any entry in history it should do history.back() If no entry in history, load a default page. }) Is it possible? Not...