javascript

Using jQuery on "native" html objects

I've just started using jQuery, but am a bit stuck. I am building a table dynamically in javascript and am adding classes all the time to cells (for styling), so I would like to use the addClass function: var row = table.insertRow(-1); var cell = row.insertCell(0); cell.addClass('boldRow'); but this does not work. I know you can use t...

addEventListener('mousedown', ...) vs element.onmousedown

Right let’s get this out the way first. Yes, I want to hide the context menu. No, I’m not trying to prevent someone lifting content off my page. Its intended use is input for an in-browser game and it will be limited to a specific area on the webpage. Moving from the ideological to the technical... var mouse_input = function (evt) { ...

Are anonymous functions a bad practice in javascript?

I was reading that using anonymous functions in javascript is bad practice, because it can make debugging a pain, but I haven't seen this for myself. Are anonymous functions in JavaScript really bad practice and, if so, why? ...

Adding scripts in updatepanel at runtime (end_request)

Hi, At my work I bumped into a problem: This page that my friend is working always create a update panel at runtime, for some reason. Assuming that I already tried to use the: Sys.WebForms.PageRequestManager.getInstance().add_endRequest It doesn't work most probably because the updatePanel is as well recreated at async request....

Javascript Anchor Jump To The Top Issue

Hi, I've added this code below to a MOSS 2007 web part inside OnPreRender() method. if (!Page.ClientScript.IsClientScriptBlockRegistered("jump_to_anchor_JS")) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "jump_to_anchor_JS", "window.location.hash=\"anchor\";",true); } The page loads, jumps to the specific anchor, ...

window.open height isn't the same in Google Chrome as other browsers

I am using javascript's window.open to open a browser window on a user click at a specified width and height (760x581), and this works correctly on Internet Explorer, Safari, and Firefox, but Google Chrome is giving me issues. In the other browsers, the height is correctly used as the height of the content, but in Google Chrome it is ma...

How to remove an unsaved event?

I am using jquery and fullcalendar to schedule activities. When users select a timeslot, a form is shown on the right of the calendar where they can enter additional details. With the 'select' callback I render a temporary event on the calendar so my users will have visual feedback while filling out the form. However, when they have mi...

The Benefits of JavaScript Prototype

I've been wondering about JavaScript's prototypal nature, and the benefits of it, and have come down to the following list : 1) Inheritance cat.prototype = animal 2) Memory Efficiency a.prototype.b = function() {} var a1 = new a(); var a2 = new a(); Then a1.b and a2.b are essentially the same object, where as : var a = functio...

Set input fields to the current value of label elements

How can I get the current value of the label elements within function showEditionBlock() and set them to the corresponding input fields? The function will show the "edit" div, but the inputs are not getting the original values of the labels. <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/j...

Add a sequence of numbers to divs

I have a list of 8 divs and need to add a sequence of class numbers to them using Jquery to style them individually. Need to add them to the 'content-block' div see example below. The desired effect will be something like this: <div class="wrapper"> <div id="content-block" *class="post1"*> </div></div> <div class="wrapper"> <div id="c...

javascript: wait for image used in code to load

Hi, Ive had a problem that I cant fix while creating an image carousel in javascript. I am using jcarousel with a few "hacky" modifications to allow images with different widths (portrait/landscape) the end result is I am using some code that looks like this function mycarousel_itemAddCallback(carousel, first, last, dir) { var thumb...

JavaScript loop running indefinately

so, i am trying to get my script to figure out the relevant last day of the school term. it needs to run until the current date is less than (as in before) the last day of the quarter. it just keeps on running no matter what. ps, i think the problem might be that it isnt resetting the "lastDayofQuarter" (at least outside of the loop). Ho...

Export Javascript Console log from Google Chrome

Is there any way to export messages logged to the javascript console in Google Chrome? If not, can anyone suggest a good way to diagnose javascript problems on a client's machine? I have not been able to replicate the problems locally, despite setting up an identical environment. ...

How can I delay the loading of CSS background images?

I am animating sprites in a HTML/JavaScript game by showing/hiding/repositioning many divs, each with a CSS background image. I'd like to load some of the images only when they are first needed, rather than loading them all when the page is first loaded. Will setting them all to "display:none" initially and then showing/hiding them wit...

Good html5 open source project

I am looking to look at some examples of projects that makes heavy use of html5 canvas and does something interesting with it. The project must have source available. Any recommendations? ...

Javascript & PHP :: What to do ??

I have a string, get by Javascript (the content of a div!); I want to write this string to PHP, because i want a text file with this content! How is the best way to do this? Edit[1]: Method Post doesn't works, because i have '<' chars and it erase them (i don't know why)... Example: I have #include <stdio.h> and when i call echo $_REQ...

Is it possible to "fake" the src attribute of an iframe ?

Hello everybody ! I try to add dynamically an iframe to a web page using JavaScript. I would like to know if that's possible to set the src attribute of my iframe without using another html file via an URL. I mean is there a way to "fake" the html for the src attribute file with a JS variable where we I can set my code (which is JS itse...

Trouble with setInterval and undefined arguments

I'm trying to create a basic strobe light in the browser using the canvas element. I'm expecting setInterval to keep calling the changeBG function to change to a random background color. This function works fine on its own, but not when called by setInterval. I tried pulling up this page in firebug and it told me that colors was undefine...

Appending after an element in jQuery

I'm using jQuery in my current project. I have an list of elements with unique ids. I would like to pick out a particular element and append a new list item after that element. For example, if I have something like: <ul> <li id="one">one</li> <li id="three">three</li> </ul> I would like to append <li id="two">two</li> after ...

jQuery - passing id element to a non-anonymous callback function without using an anonymous function

I'm trying to pass an element's id to storePair $("#someid").click(storePair($(this).val(),$(this).attr("id")); using $(this) doesn't work. no value. Another stackoverflow post suggests that I use an anonymous function as a wrapper for StorePair(val,id), i.e., $("#someid").click(function(){storePair($(this).val(),$(this).attr("id")}...