javascript

How to wrap the click event with some custom function

I have a button called 'create project', when user click the button, i want 2 things to happen an ajax call to check if the user is allow to create a project if allowed, then execute the button as normal, if not, then pop up a modal dialog saying he is not allowed to create a new project. I have the following code $('.create_proje...

javascript prototype inheritance

This seems inconsistent, but probably is due to the fact that I'm new to javascript's prototype inheritance feature. Basically, I have two base class properties, "list" and "name". I instantiate two subclasses and give values to the properties. When I instantiate the second subclass, it gets the list values from the first subclass i...

javascript gotcha: empty list to boolean conversion

Why both [] == false and ![] == false are true? ...

Regex/lastIndex - Unexpected behaviour

I know there are a few regex/lastIndex discrepancies but this one is new to me! Expected behaviour: Creating a new regular expression (with literal/constructor) will, obviously, create a new RegExp object with a lastIndex property set to zero. Actual behaviour: (in FF, Chrome): The lastIndex property seems to persist through multiple R...

Secure AJAX connection / null character SSL cert attack?

I came across aSSL, which appears to be a couple of years old and was wondering if anyone has other examples of "secure" AJAX connection code? Obviously, this wouldn't be as secure as using a SSL certificate, but with the null character SSL attack out there (recently demonstrated against PayPal), would it be worthwhile to revisit someth...

Three map implementations in javascript. Which one is better?

I wrote a simple map implementation for some task. Then, out of curiosity, I wrote two more. I like map1 but the code is kinda hard to read. If somebody is interested, I'd appreciate a simple code review. Which one is better? Do you know some other way to implement this in javascript? var map = function(arr, func) { var newarr = []; ...

Best Method: Parsing CSV file and Passing back to front end using AJAX

Hello all, I have a CSV file that is uplaoded to my server where a PHP script will parse and return output to JavaScript via AJAX. The CSV file is made up of two rows. First row contains the column names and the second row contains the data. I am trying to write a script that will parse it in a form that will be usable by Javascript to...

How does Google Friend Connect accomplish cross domain communication without needing to upload a file to the client domain?

Previously, Google's Friend Connect required users to upload a couple of files to their websites to enable cross domain communication and Facebook Connect still requires you to upload a single file to enabled it. Now, Friend Connect doesn't require any file upload... I was wondering how they were able to accomplish this. Reference: htt...

Assign the 'onmouseover' event handler.

Hey all, Please tell me what is wrong with this code: <script type="text/javascript" > function createimg() { var img = new Image(); img.src='link/to/image'; img.alt='Next image'; img.id = 'span1'; img.style.zIndex = 10; img.style.position = 'absolute'; img.style.display='block'; img.style.top =...

XSL parsing is shortening script tag causing issues in IE

I have a C# application that generates an html document from transforming an xml file with an xsl file. In my xsl template I reference an external javascript file like this: <script language="javascript" type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" ></script> after the transformation the previ...

check if mouseover is fired??

Dear All, in Javascript: Is there a way of checking if a mouseover event for some element has fired? If yes, how? T ...

Capture contents of Firefox/IE error console through code?

Is it possible to capture the contents of either the Firefox or IE javascript error console? I'm thinking adding a feature where when a user clicks the 'Report A Bug' link on my site, it also sends along the contents of the console, incase there are any useful errors in it. That way I don't have to tell them to manually open it and copy ...

Simple Toggle with Mootools: What am I doing wrong?

<script type="text/javascript"> $(document).ready(function(){ $("#trigger").click(function () { $("#trigger-banner").toggle(); }); </script> Help? Thanks! ...

Simple tooltip plugin/js for rails

I really don't want to use prototip or prototip2 because I have to pay for them and I only need to do one very simple alert. The user will submit a remote form and then a small alert will come up and fade out after 5 seconds or so. It doesn't even need any fancy styling. I'd ideally like to use scriptaculuos over jquery. I just have no i...

How to find out if an element contains only a £ sign with JQuery?

Hi Guys, Say I have 2 divs: <div>&pound; 21.99</div> <div>&pound;</div> If I only want to select the div that contains the symbol only, how would I go about this? I have tried: if ($('div:contains("&pound;")').length > 0) { $(this).addClass("pound"); } ...

How to use javascript (or something) to make a grid with dragable points that will modify a curve in realtime?

I want to make a box on the page that contains a graph with a curve on it, then user can drag a few points around modifying the curve. Preferably javascript or something I can easy share variables with DOM and ASP.NET. I want to get out a certain number of the points. Creating new points and deleting them would be great too. This way I c...

Apply random color to class elements individually?

My goal is to each div with a class of "main" to have a random background color. I have the script that generates the random color but, using jquery, I only seem to be able to apply it to all divs in the class. How can I select a div, apply the color, select the next div in the class, generate a new random color, apply it and repeat? Her...

How to display entities taken from XML with Javascript?

There MUST be an easy way to do that! I didn't want to ask this question again if somebody already asked it but I couldn't find something similar in this site... anyway : So I have a XML file : <marker>This is a test &amp; it&#039;s fun. &eacute;</marker> So when I read this XML file with Javascript, I want to put it in a text input ...

JS: How to dynamically insert text into a SPAN?

Without using any JavaScript frameworks, how do I dynamically change the text within a SPAN element. I know how to do this with a DIV, it would be the following: document.getElementById('myDiv').innerHTML = '...' What's the equivalent of this for a SPAN element? ...

How to exclude iframe in Greasemonkey

I have created a greasemonkey script for a website. What the script does is adding a div at the end of the page. document.body.insertBefore(myDiv, document.body.firstChild); But now the site adds an iframe for google-ads, as a result my div appears in the iframe too, which is not what i want.How can i avoid the script to affect ifr...