javascript

Does Java 6 include a program that can run javax.script (Rhino JS) files?

I found that Java 6 includes Rhino JS (except for one or two minor pieces), as javax.script. Pretty cool! Does a Java 6 install (JRE or JDK, either) contain a binary that I can simply point to a .js file to run? (I think it would be great to be able to provide source code for others to read and run, without compilation, and require on...

Given a set of top/bottom pixel ranges, how do I find which one has been scrolled into?

The Problem As the page is scrolled from top to bottom, the user will pass through these ranges. Suppose they are values in an alphabetical address book: as they scroll from top to bottom, they will pass from A to Z. There are tabs on the side labeled with the names of sections in the document, labeled 'Aa-An', 'Am-As', etc. What I wan...

Test if a selector matches a given element

Hi guys. Is there any way to test if a selector would match a given DOM Element? Preferably, without the use of an external library like Sizzle. This is for a library and I would like to minimize the amount of third party plugins required for the "core" library. If it ends up requiring Sizzle I'll just add that as a plugin to the librar...

Can a method find out the "this" of its parent object?

Let's say I've come up with a particular sort function that I want to put in the prototype of some Array based object (I'll use Array itself here). I can do Array.prototype.specialSort = function... but what I'd really like to do is Array.prototype.sort.special = function... the problem, of course, is that when it's called, the lat...

Is there a way to create your own HTML element?

Is there a way to create your own HTML element? I want to make a specially designed check box. I imagine such a thing would be done in JavaScript. Something akin to document.createHTMLElement but the ability to design your own element (and tag). ...

arguments.callee question

I know it's possible to call the calling function, but is it possible to call the function calling that function. Ok ... that sounds a little confusing. Let me demonstrate: pop.share(msg, function(response) { if(response) response = true; else response = false; }); Basically a box pops up to ask the user to share. If the respo...

how can i make an javascript object for a HTML form

i want to make an object which can do all the actions my form needs -- it can validate the form, submit the form, and so forth. i want javascript to do all these things. i no longer want to write same code several times over in procedural fashion javascript in global namespace. i want to create Javascript object to handle these functions...

Google Maps v3 opens the last infoWindow when a marker is clicked

I have a shared infoWindow for all my markers. It works good if I use jquery's $().each(function(){}), but if I change it to JavaScrips's native for or while loop, it's not working as expected. Whenever I click a marker, it will open the last populated marker's infoWindow, instead of the clicked marker's infoWindow. This works: $(sto...

After the DOM is ready, IE will not show page content when Javascript is modifying the DOM? (but Firefox will show)

I have a page that will initialize jCarousel when the DOM is ready (by jQuery's $(document).ready()), but on IE 8, the page is not displayed until jCarousel has finished initializing, which can be 1 minute later. On Firefox and Chrome, the page content is shown right away, while letting jCarousel do its job. So is it true that IE will...

How to get the user's location from iPhone using Google Maps API v3?

I want to make a google map on the iPhone and show the user's location when they first open the site. But i can't find this method on Google Maps v3 api. So i think maybe the iPhone has the function to do this. Does it? ...

Document.write being cached

I am using a script before page load to write some html into my page with doucment.write now this gets cached like crazy only a hard refresh seems to update it. Now before everyone goes "OMG DONT USE DOCUMNNT.WRIT" I will be getting rid of it but for the moment I need a quick fix. So is there a way I can force this script to update eve...

How can I trigger JavaScript to execute after a Silverlight applet loads?

I am working on a project where I have a lot of interaction between JavaScript and managed code. In fact, I need the JS application to interface with the Silverlight application in the page right from the beginning. So I need the Silverlight application to load before the JS code gets executed. But while doing so, most of the times I g...

Real time GPS Tracker on JUST HTML / JS and Google Maps to be run on a handphone? Is it possible?

I have read up on GPS Real time tracking and found out several things about it, mostly requiring PHP, zope and a database to store the incoming data. Some other methods uses ajax with relations to PHP. As regards to my question, is it possible to do so with just html and JS, using markers or anything else to populate the Google Map whe...

Javascript profiler shows each() spending a lot of time, but how to find where it is?

IE 8 and Firebug's Javascript profiler both showed that jQuery each() spent a lot of time, but since the each() is not inside a function, there is no way to tell which line it is, and there are lots of these each() in the global scope of the source code. On Firebug, it can show you the file and line number, but it will take you to jQuer...

jQuery Event Bubbling, live(), click event not propogating.

I have two containers, one that isn't generated until the page has loaded. The one generated last (<div class=last></div>) should appear over the first one. Visually it does cover up the first one. However, I cannot get the ".last" to respond to a live() click event. It will respond to the first div, but not the last div (again, the div ...

Using JQuery .getJSON to read in an array

Hi, I aam trying to GET an array from a JSON file using JQuery's ajax methods. Specifically, I want to make the ajax request on document load and use the acquired data in other functions. Here is my code: $(document).ready(function() { getJSON(); clickEvents(); }); function getJSON() { $.getJSON('goods.js', function(data) { cra...

Javascript Span as PHP Variable

As the title suggests, I have a span that is automatically generated by SimpleCart (Javascript Cart) - I want to use that span with a different checkout gateway then they support. Therefore, I need to take some of their tags and "echo" them into PHP variables. For example: <input type="hidden" name="fltAmount" value="###"> <span clas...

How do I loop through a JSON object that contains arrays?

How would I loop through this correctly? {names:['oscar','bill','brad'],ages:['20','25','18']} So i'd basically get the output: names: oscar ages: 20 names: bill ages: 25 names: brad ages: 18 Yes I know its a for...in loop but I just can't figure out how to get this output. ...

How to access a document.doc and .txt modify the content using javascript

Is it possible to access the .doc files and update in that document using javascript . Thanks ...

How can I reduce the size of an iframe without having the content cut?

I have a page that loads another page(url) onto it. The problem is that the iframe page does not fit well in the outer page. How can I reduce the size of the iframe page having the content of the iframe page intact? I do not wish to have scroll bars. ...