javascript

Jquery checkboxes manipulation help

Using jquery, how can I: 1- Have all checkboxes on a page turned checked on or off? 2- Loop through all the checkboxes on the page which are selected. I.e something like this $(sel-cboxes).each(myFunction); So myFunction would be called on each selected checkbox. Thanks in advance! ...

How to get a count of all checked checkboxes on a page

I want to count how many checkboxes a user has selected. For example, from a group of 10 checkboxes if he selects 5, then I want to be able to count it. Using the line: $(":checkbox:checked") I can select all of the checked checkboxes, is there a way to get the count of all the elements that are returned by that statement as well? ...

Javascript swap array elements

Is there any simpler way to swap two elements in an array? var a = list[x], b = list[y]; list[y] = a; list[x] = b; ...

iframe location is null

Sometimes I use: window.frames[framename].location.href ..only to find firebug reporting window.frames[framename].location is null, why would this be? ...

port python code to javascript

indices[i:] = indices[i+1:] + indices[i:i+1] Hope someone helps. ...

JavaScript build options/tools

These days I find myself shifting out more and more work to the client side and hence my JS files tend to get bigger and bigger. I have come to the point where most HTML pages have half a dozen or more JS imports in the header and I realised that this is hurting loading times. I have recently discovered this script which lets you downlo...

window.onbeforeunload message localization

Hello, I'm using a page unload trigger to warn the user of unsaved changes while leaving the page/closing the tab/etc... and this works fine. //Exit event if (!changes_saved) { window.onbeforeunload = confirmExit; } function confirmExit() { return "Your changes will be lost if you leave this page!"; } My problem is that the brows...

Howto get iframe linking to internal document source using javascript/jQuery?

Hi there, I have an iframe with id "appframe", the source is page.html and it's on the same server. I want to get the source of the page using jQuery. alert($("#appframe").contents().find("html").html()); returns <head></head><body></body> even though the document does not contain those tags, it only contains "Default page" - any ide...

Firefox 3 Extension Javascript Duplicated Event Listener on Load

I was fixing up an extension that was written for Firefox 2 to work with Firefox 3. One of the changes was to use: window.getBrowser().addEventListener("load", checkURL, true); instead of going through just window. The only problem is that the "load" event seems to occur more than once per page load. I have also tried listening for "D...

javascript image overlay over a specified div

i am new at javascript. very new actually, this ought to be my first script. can anyone explain to me how to make a transparent overlay over any specified fixed width region, say 700x300px. ...

How to access main window element from iframe

I hope someone can help with this issue. I have a popup iframe using lytebox. I would like it that when i click a link in my iframe with the class "mylink" that it executes the ajax call and update a div in my main window with the id "mydiv". I know how to do the onclick events and the ajax call but i do not know how to access the "mydiv...

How can I use fancybox using onclick?

Hi I am trying to make use of JQuery and Fancybox. This is how it should be used: http://fancy.klade.lv/howto However, I can not generate many ids for "a href" and I do not want to make many instances of fancybox ready. So I want to be able to use one fancy box instance for many hyperlinks that do the same thing. Whenever any of thes...

Problem with OO programming in javascript and ASP.NET AJAX

Hi, I'm trying to keep as much OO as possible, but ASP.NET AJAX seems to be doing something strange after returning from the server... function Person( personId ) { var id = personId; var firstName; var lastName; this.initializeStep1 = function() { PeopleServices.getFirstName(id, this.initializeStep2); } this.initializeStep2 = fu...

In javascript how do I retrieve implementing subclass name

Hi. Say I have an "abstract class" like this: function AbstractClass() { this.getImplementingName = function() { return /* how do I get this? */; } } and an implementation like function ImplmentingClass() { } ImplmentingClass.prototype = new AbstractClass(); var impl = new ImplmentingClass() var name = impl.getImp...

How to retrieve the value of a text area in javascript

I have a form with a text area input. I'm using JQuery to submit the form via an AJAX request in order to update a database. My problem is that I'm having difficulty retrieving the data from the text area input. If the input has an id of "txtBody" I have tried: var body = $("#txtBody").val(); // This adds 'undefined' to the database v...

How to display an image in a fixed div to make a scrollable image panel?

i am making a photo gallery script that involves displaying an image in fixed width/height box. now i want that image to display in its complete size. i mean, if the box is 700x300 px, the image should not resize to 700x300 but should display at its own full resolution. also if possible, can i somehow make it drag around in the box so th...

What is the simplest way to implement "server push"-like behavior for a web page?

I'm attempting to make a very simple 2-person chatroom for my Django site. I'm learning AJAX to do this. I need parts of the web page to update without user interaction: When User 1 sends a message, it should appear on User 2's screen When User 1 logs off, his status should change to "offline" on User 2's screen What is the simplest ...

How to make a div popup after 10 seconds or so (using javascript or php)?

Is there a way to make a div popup in the center of the page after 10 seconds after the page loads? ...

How do you deal with asp.net server callbacks within javascript objects?

I'm having a problem with using server callbacks to webmethods within an object in javascript... function myObject() { this.hello = "hello"; var id = 1; var name; this.findName = function() { alert(this.hello); //Displays "hello" myServices.getName( id, this.sayHello ); } this.sayHello...

javascript option select problem

I got this javascript code from off the internet. It's a script that changes a picture and it caption from the selection of an options drop down box. The script works fine. The only problem that I have is that the value in the option box can only be numbers. Is there anyway to tailor this whereas the value within the options parameter ca...