javascript

Dynamically retrieve Html element (X,Y) position with JavaScript

Hi all I want to know how to get X and Y postion of HTML elements such as img, div in JavaScript. thanks ...

load aspx in div or adjust the size of a iframe

Hello, I have a htm file with an iframe and a menu structure. The menu can load a htm file in the iframe or a aspx file. No problem at all. But... Now they want the iframe to get the size of its content. (so there will be no scrollbar in de iframe, but you have to scroll the whole htm file) I didn't get this to work so I thought I wou...

Find callback functions added with jQuery on DOM elements

I am currently testing this in Mozilla FireFox 3.0.5 using FireBug 1.3.0 with jQuery 1.2.6. First try document.getElementById("x").onfocus = function () { var helloWorld = "Hello World"; }; FireBug console: document.getElementById("helloworld").onfocus.toString() = function body as a string $("#helloworld").get(0).onfocus.toStr...

ASP.NET & JSON: Function to convert GridView and Repeater in a JSON string.

Hi Guys, I need a JavaScript function which will take the Asp.net Repeater as input. The function must then parse through the object and return the data in the the rows of the object as JSON. I can them send the JSON back to the server to be interpreted/parsed and saved to the db. ...

How can one de-reference JavaScript variables when enclosing an outer scope

Ok, here's a problem script. var links = [ 'one', 'two', 'three' ]; for( var i = 0; i < links.length; i++ ) { var a = document.createElement( 'div' ); a.innerHTML = links[i]; a.onclick = function() { alert( i ) } document.body.appendChild( a ); } This script generates three divs: one, two and three, using an array. I'...

Calling Javascript on a page programmatically (in c#) and then submitting it back to the server

I need to request a page (I'm using httpwebrequest at the moment), call some javascript ( e.g function selected(id) { document.getElementById("selected").value = id; } and then submit that back to the server . . . is this possible? EDIT Sorry for the vagueness. The page I'm trying to interface with is already 100% work...

submit a form via Ajax using prototype and update a result div

Hello, I'm wondering how can I submit a form via Ajax (using prototype framework) and display the server response in a "result" div. The html looks like this : <form id="myForm" action="/getResults"> [...] <input type="submit" value="submit" /> </form> <div id="result"></div> I tried to attach a javascript function (which uses...

Mouse coordinates in Internet Explorer

I have a map for my game, I have a script that on a click displays an alert of the mouse coordinates on the map. The map scale is 1 map unit to 2.5 pixels and the map starts at -600, 600 and goes down to 600, 1700. Thus I can't simply throw out the pixels of the mouse. I got it working (and was pretty happy about it) but alas IE (6) ha...

How can I get greasemonkey to call a function on a page after it loads

I have a very simple greasemonkey script that I want to call an already existing javascript function on the page. I've read the documentation and nothing seems to work window.setTimeout(function() { alert('test') // This alert works, but nothing after it does myFunction() // undefined window.myFunction() // undefined do...

Why don't Django admin "Today" and "Now" buttons show up in Safari?

I'm developing a Django application that contains a model with a date/time field. On my local copy of the application, the admin page for that particular model shows this for the date/time field: This is as expected. However, when I deploy to my webserver and use the application from there, I get this: The application on the server...

Do you recommend using semicolons after every statement in JavaScript?

In many situations, JavaScript parsers will insert semicolons for you if you leave them out. My question is, do you leave them out? I'll post simple Yes/No answers as a poll, but I'm also interested in your reasons. If you're unfamiliar with the rules, there's a description of semicolon insertion on the Mozilla site. Here's the key poin...

Object Oriented questions in Javascript

I've been using javascript for a while, but have never learned the language past the basics. I am reading John Resig's "Pro Javascript Techniques" - I'm coming up with some questions, but I'm not finding the answers to them in the book or on google, etc. John gives this example in his book: Function #1 function User( name, age ){ th...

Prevent a user from closing a browser window using "X"?

Can I tell, using javascript, whether a user has clicked on the "X" icon on a browser dialog, or the "OK"/"Cancel" buttons? I have code I need to run when the window closes, but it will only run when OK or Cancel are clicked. I currently capture the onunload event of the window. How can i accomplish this? window.onunload = function() {...

In firefox, how to change color of text in a treecell using javascript

BACKGROUND: I have the following XUL fragment <tree id="treeToChange" flex="1"> <treecols> <treecol label = "First Column" id="c1" flex="1"/> <treecol label = "Second Column" id="c2" flex="1"/> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Data for Column 1"/> <treecell label="D...

Is there a windows utility similar to HTML Tidy for Javascript

I want to cleanup some javascript files and reformat them with nice indents, etc, Any recommendations for utilities to do this under Windows ...

Javascript: Lazy Load Images In Horizontal Div?

I have a div that has a bunch of thumbnails showing horizontally (with a horizontal scrollbar). Is there a way to lazy load these thumbnails and only show them once the user horizontally scrolls to their position? All the examples I've seen check the browser window, not a div. This is for contest entries so sometimes there are hundreds ...

Spinning javascript menu

I would like to create a spinning menu akin to the one done in flash here. Are there any relevant links you know about to help with this endeavor? Thank you kindly. ...

Move X number of rows in a table using jquery

I'm trying to move X number of rows down in a table using jQuery... I can do the following and it works.... /* Now let's move next 3 times to arrive at the foo account */ for (var rowCount = 1; rowCount <=3; rowCount++) { foobarRow = $(foobarRow).next('tr'); } I realize I could go foobarRow = $(foobarRow).next('tr'); ...

jQuery scope or race condition in AJAX/getJSON

I have a piece of jQuery code which invokes several getJSON() calls in quick succession: var table = $("table#output"); for (var i in items) { var thisItem = items[i]; $.getJSON("myService", { "itemID": thisItem }, function(json) { var str = "<tr>"; str += "<td>" + thisItem + "</td>"; str += "<td>" + json...

jQuery 1.3 - Issue with Setting an Attribute Value

This is my first stackoverflow question, so try to be nice. ;-D My issue is this, I am refactoring some existing javascript code and using jQuery to do it. In several places I've come across javascript code similar to the following: // some js code working with the customAttribute value javascriptElementObject.customAttribue = void(0);...