javascript

Help with jQuery selection.

I figured enough jQuery to select this chunk out of a huge HTML document. I want to select the value of subject, body, and date_or_offset. (these are name attributes as shown below). How do I go about this. Assuming this print is from alert($(this).html()) inside a call back function. <p><label for="first">Subject</label> <br> <...

I have a huge set of elements and jQuery's each() function is killing my browser - How can I improve my code?

I'm using two plugins I wrote to find all the radio/checkbox inputs and select boxes in a form and them style them. I now have a large form which a lot of checkboxes and Firefox is hanging as my plugin tries to style each of them. Here's the plugin code: (function($) { $.fn.stylecheck = function(options) { /* Para...

chrome extension memory hog with basic function

Hey all, I have a chrome extension thats very complex, but I'll simplify the issue which can be reproduced easily. manifest.json: { "name": "script", "version": "1.0", "description": "script", "browser_action": { "default_icon": "icon.jpg" }, "permissions": [ "tabs", "http://www.google.com/" ], "background_...

How to get the overlay to display for jquery ui modal dialog?

In the demo, the overlay is displayed correctly and all elements underneath the overlay are disabled: <div class="ui-widget-overlay" style="width: 1920px; height: 650px; z-index: 1001;"></div> However, when I use the code in my page, I can still access the other controls underneath the overlay. Any ideas on how to fix? I've been loo...

Decimal check on OnKeyUp event

I have couple of text boxes. In those text boxes I need to check few types. Allow only Numbers and Decimals Ex: 123.2323 //not allowed any characters Allow only 2 numbers after decimal Ex: 123.23 //not allowed any characters and only allowed 2 digits after decimal Allow only 1 number after decimal Ex: 123.2 //not allowed any cha...

Is there any way I can see how long a JQuery AJAX call takes to execute?

Hi folks, Is there anyway to see how long a simple $.getJSON method takes to call using some type of timing code, in jquery/javascript? Secondly, is there any way to see how BIG the response Content-Length is, in kB or megabytes? ...

How would I go about creating a form with live updates in iWeb?

I'm using iWeb to create a webpage. I'm trying to create a feature where the user can type something in a field, like a comment, and it would display without refreshing the page. Below the area where the comment is typed up by the user, the comment as well as other comments would display. I believe I'd store each comment in a text file f...

JavaScript: Decimal Values

What can I use as a decimal type in JavaScript? It's not supported (0.1 + 0.2 !== 0.3), and I need it for representing exact values in a banking/financial application. See The State and Future of JavaScript for an good read and the dirty details behind JavaScript and its (lack of) support for decimal arithmetic. By "decimal", I mean eit...

JavaScript looping through an object while adding items

I have the following code segment: var run = 0; var obj = {'item1':0,'item2':5,'item3':10}; for (var i in obj){ run++ obj['newItem'+run] = 5; } return run; and it returns 3. But I want it to go on infinitely and eventually crash the browser. Is there any way of updating the obj variable while in a for loop? ...

remove carriage return only inside the span with regexp

I have this piece of text in a string: <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><i style=""><span style="" lang="ES-TRAD">some text another text<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" al...

control html5 video player loop with JavaScript

I am looking to enable looping of html5 video in browsers that do not support the loop tag (ff) with JavaScript. Does anyone know the feasibility of accessing the end of the video play and reverting play back to zero? ...

JavaScript multiple namespaces

I have a large js file that I want to break into multiple namespaces. Is this a good/bad approach vs keeping everything in one namespace? In NAMESPACE_FIRST how do I call map build? var NAMESPACE_FIRST = { init:function() { alert("onload functions"); }, this.map:function() { this.length = 0; }, th...

How to attach both an onclick() and href to an <a> element, but only have one work at once

Hi, I have an element like so: <a class='link' href='/page1'>Page 1</a> It has a click handler attached like so: $('.link').click(function() { loadPage('page1'); }); When the link is clicked, the new page loads. However, there are two ways of loading the new page. One is via AJAX, which figures out which elements have changed betwee...

Inline Javascript causing jQuery Cycle plugin to stop

I am new to jquery and Javascript and I am running into a problem which I hope somebody here will be able to solve. I have setup a jquery Cycle plugin to display some content in a div. Now I also have certain links load some different content in another div. Upon load, the cycle works fine, but when I click any of the links and load the ...

how to remove a key from a JavaScript object?

Let's say we have an array with this format: var thisIsArray = { 'Cow' : 'Moo', 'Cat' : 'Meow', 'Dog' : 'Bark' }; i wanted to do a function that removes by key: removeFromArrayByKey('Cow'); ...

How to call a javascript function once on page load, page reloads, don't call it again

On a Magento shopping cart, there are 2 forms that need to be filled out: shipping estimate and coupon code. Each refreshes the page after submitting the form. The shipping estimate form needs to be submitted before the coupon form so that the coupon can validate the country. What I'd like to do is to call the shipping form's coShippin...

Difference Between MS Ajax with JS and Ajax

Hey my Question is What is The Difference Between MS Ajax n Simple Ajax library. is Ms Ajax contain the JavaScript in it and what are the feature enhance with the addition of JS in it. Share link about the Differences. ...

how to pass the user_id on escape javascript while render on jquery

How can I pass the user_id on escape javascript while render on jquery? Eg: <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $("#addPerson").click(function(){ $("#user tr:last").after("<%= escape_javascript(render :partial => 'user_item', :locals => {:user_item => User.new}) %>") ...

HTML5 Canvas flip vertical function works in Firefox but not Chrome or Safari. why?!

Here is the code that works perfectly well in Firefox, but I just do not get why it does not work in Webkit browsers! Note: Im using jQuery to select the canvas element. (function() { flipV=function(imageData) { var n = new Array(); var d = imageData.data; // loop through over row ...

How do I assign an incremental z-index # for each H2 using Jquery.

Using Jquery, How do I assign an incremental z-index # for each H2, incrementing by 2's? (when document is ready, start with the first H2 and give it a z-index of 2, then go to the next H2 and give it a z-index of 4.... etc. z-index of the next H2 is 6 etc. example: <H2 style="z-index: 2;">heading one</h2> <H2 style="z-index: 4;">headi...