javascript

Passing JS function to applet for as event listener

Is it possible to pass a function/callback from javascript to a java applet? For example i have an applet with a button that when pressed it will call the passed js callback function onCommand() {alert('Button pressed from applet');} applet.onCommand(onCommand); ...

Why is it not a good idea to use SOAP for communicating with the front end (ie web browser)?

Why is it not a good idea to use SOAP for communicating with the front end? For example, a web browser using JavaScript. ...

What is the preferred method of commenting javascript objects & methods

I'm used to atlas where the preferred (from what I know) method is to use xml comments such as: /// <summary> /// Method to calculate distance between two points /// </summary> /// /// <param name="pointA">First point</param> /// <param name="pointB">Second point</param> /// function calculatePointDistance(pointA, pointB) { ... } R...

Best way to safely read query string parameters?

Hello all, We have a project that generates a code snippet that can be used on various other projects. The purpose of the code is to read two parameters from the query string and assign them to the "src" attribute of an iframe. For example, the page at the URL http://oursite/Page.aspx?a=1&amp;b=2 would have JavaScript in it to read the...

Why should I use Flex?

In a recent conversation, I mentioned that I was using JavaScript for a web application. That comment prompted a response: "You should use Flex instead. It will cut your development time down and JavaScript is too hard to debug and maintain. You need to use the right tool for the right job." Now, I don't know too much about Flex, but I p...

Tag images in the image itself? HOW-TO

How to tag images in the image itself in a web page? I know Taggify, but... is there other options? Orkut also does it to tag people faces... How is it done? Anyone knows any public framework that is able to do it? See a sample bellow from Taggify: ...

Display DIV at Cursor Position in Textarea

For a project of mine I would love to provide auto completion for a specific textarea. Similar to how intellisense/omnicomplete works. For that however I have to find out the absolute cursor position so that I know where the DIV should appear. Turns out: that's (nearly I hope) impossible to achieve. Does anyone has some neat ideas ho...

jQuery $().find problem

I'm trying to get the contents of a XML document element, but the element has a colon in it's name. This line works for every element but the ones with a colon in the name: $(this).find("geo:lat").text(); I assume that the colon needs escaping. How do I fix this? ...

JavaScript intellisense in Visual Studio 2008

Have you guys and gals got any tips or hacks for making the most out of the JavaScript intellisense options in Visual Studio 2008? Consider the following: var Persons = {}; Persons.Females = {}; Persons.Females.Julie = function (_mood) { /// <param name="_mood">Mood of Julie</param> /// <summary>Constructor function: Julie...

HTML: What's the effect of adding 'return false' to an onclick event ?

Many times I've seen links like these in HTML pages: <a href='#' onclick='someFunc(3.1415926); return false;'>Click here !</a> What's the effect of the return false in there ? Also, I don't usually see that in buttons. Edit: Is this specified anywhere ? In some spec in w3.org ? ...

What good template language is supported in Javascript?

Templates are a pretty healthy business in established programming languages, but are there any good ones that can be processed in Javascript? By "template" I mean a document that accepts a data object as input, inserts the data into some kind of serialized markup language, and outputs the markup. Well-known examples are JSP, the origin...

Accessing created DOM elements

Hi, I have code to create another "row" (div with inputs) on a button click. I am creating new input elements and everything works fine, however, I can't find a way to access these new elements. Example: I have element <input type='text' id='name_1' name="name_1" /> I then create element <input type='text' id='name_2' name="name_2" /...

How does Google's javascript API get around the cross-domain security in AJAX

How does Google's API make cross-domain requests back to Google, when it's on your website? ...

Passing in parameter from html element with jQuery.

I'm working with jQuery for the first time and need some help. I have html that looks like the following: <div id='comment-8' class='comment'> <p>Blah blah</p> <div class='tools'></div> </div> <div id='comment-9' class='comment'> <p>Blah blah something else</p> <div class='tools'></div> </div> I'm trying to use jQuery...

JavaScript or Java String Subtraction

If you are using Java or JavaScript, is there a good way to do something like a String subtraction so that given two strings: org.company.project.component org.company.project.component.sub_component you just get sub_component I know that I could just write code to walk the string comparing characters, but I was hoping there was a ...

Javascript and session variables

I have a database that stores events in it and a page with a calendar object on it. When rendering the days it looks through the months events and if any match the current day being rendered it creates a linkbutton to represent the event in the day on the calendar and adds it to that cell. I add some javascript to the linkbutton to chang...

ASP.NET not seeing Radio Button value change

I have a form with some radio buttons that are disabled by default. When a value gets entered into a text box, the radio buttons are enabled via javascript. The user then selects one of the radio buttons and clicks on a submit button which posts back to the server. When I get back to the server, the radio button that user clicked is n...

IE TextRange select method not working properly

I'm having an unusual problem with an IE document with contentEditable set to true. Calling select() on a range that is positioned at the end of a text node that immediately precedes a block element causes the selection to be shifted to the right one character and appear where it shouldn't. I've submitted a bug to Microsoft against IE8...

Are there constants in Javascript?

If not, what's the common practice for specifying variables that are used as constants? ...

JavaScript data formatting/pretty printer

I'm trying to find a way to 'pretty print' a JavaScript data structure in a human-readable form for debugging. I have a rather big and complicated data structure being stored in JS and I need to write some code to manipulate it. In order to work out what I'm doing and where I'm going wrong, what I really need is to be able to see the d...